1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to remove previous/next links from my WP post, but not from categories

Discussion in 'WordPress' started by lowriderzzz, Nov 29, 2016.

  1. #1
    Hello!

    I recently started learning CSS and PHP in order to customize the themes of my websites.


    I have a specific question: how can I remove previous post/next post links just from the posts, but not from the categories?

    I tried in style.css with the command

    .previous,
    .next {
    display: none;
    }


    but doing that the links from the category pages (where all posts are listed) also got removed.

    Thank you!
     
    lowriderzzz, Nov 29, 2016 IP
  2. th.sigit

    th.sigit Well-Known Member

    Messages:
    178
    Likes Received:
    32
    Best Answers:
    1
    Trophy Points:
    135
    #2
    Do it on the template files. Your single posts is using a template (usually) called single.php, while your categories is (usually) using a template called archive.php (id is also being used by many other index pages such as blog page, terms page, etc. The code for prev/next nav are within both templates. Remove it from single.php but keep it in archive.php (or their derivatives).

    Search for "wordpress template hierarchy" for more info.

    If you do not want to mess with templates, your css might work if you give it this rule:

    .single .previous,
    .single .next {
    display: none;
    }
    Code (markup):
    I say "might" because I do not know which CSS class is defined in your theme. <div class="single"> is the most common one in wordpress universe.

    As always, you might want to do any of above in a child theme.
     
    th.sigit, Nov 29, 2016 IP
    Arick unirow likes this.
  3. lowriderzzz

    lowriderzzz Member

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #3
    Thank you! That worked just fine...
     
    lowriderzzz, Dec 3, 2016 IP