• 0
Sign in to follow this  
Followers 0

Make PostNav category-specific?


Question

Posted · Report post

Dear Pagelines team, leafing through the Forums, I found an old solution to a problem I am facing: How to make the PostNav section include posts from the same category only? This is the suggested fix:

 

BEST ANSWER The Farside14 August 2012 - 04:06 AM

I seem to have figured it out, but if this is wrong or if there is another way, let me know.
Here is what I've done in the sections directory for postnav section.php
 

<span class="previous"><?php previous_post_link('%link', $link='%title', $in_same_cat = true); ?></span>
                <span class="next"><?php next_post_link('%link', $link='%title', $in_same_cat = true); ?></span>

 

I found the postnav section.php (wp-content/themes/dms/dms/sections/navbar). Do I just add the above code? And would it still be valid in DMS2 (it's ancient - from 2012!) I am hesitant as I am always afraid to break things when dealing with PHP. Or is there another way, a plugin or child theme that lets me add this in a safer way (and one that may withstand upgrades)? 

 

Thank you for your help and advice. It is always a pleasure working with Pagelines, every day!  I should say that more often, but of course yet again it is only when there is a problem that I get in touch...

 

Yours faithfully, Jan.

Share this post


Link to post
Share on other sites

2 answers to this question

  • 0

Posted · Report post

Hi Jan,

 

The best thing to do when doing something like this is for you to create a child of that section via a child theme. Then replace the code you and see if it works, I can't guarantee it unfortunately.

 

To create a child section, first you're going to need a child theme, you're free to use mine here - http://dannyholt.github.io/skeleton download the advanced version which contains a section directory.

 

Then you're going to need to copy the PostNav section folder into your child themes section directory. Then make your necessary changes, this will override the core section with the child.

 

If the code doesn't work, please let me know and I will add it to our feature request tracker.

Share this post


Link to post
Share on other sites
  • 0

Posted · Report post

Thank you, Danny, for this advice and for the child theme link. I will try my hand at this - it will be good to learn about these things anyway! A built-in feature for PostNav would be great though. There are a few previous-next-post-navigation plugins that do this, but they are old and have not been maintained. Maybe that means that it is a rare request. But it would be very useful. Anyway, I'll let you know how I get on. Yours faithfully, Jan.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0