Jump to content

Archived

This topic is now archived and is closed to further replies.

caspersjan

Make PostNav category-specific?

Recommended Posts

caspersjan    13
caspersjan

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
Danny    1,327
Danny

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.


Please search our forums, before posting!

Share this post


Link to post
Share on other sites
caspersjan    13
caspersjan

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

  • Similar Content

    • JP
      By JP+
      Hello,
      We are working on a 2 languages site (https://liguecardioliga.be) with wpml, and lately the call of a category in the loops section (and all the sections requiring a category to select posts) doesn't work in the translated language. It worked well until recently so I wonder if it's because of a recent update (wordpress, wpml, pagelines, a plugin?). Anyone has the same problem? a solution?
      TIA
    • Queue-it
      By Queue-it+
      Hi,
      Previous webmaster has made short codes assigned to certain categories. For example: [pl_section section="loops" id="003"]  displays all the Job posts for tech. 
      But where can I assign a short code for a certain category? I can't find where to add the loop ID for the category.
       
      Thank you
       
    • Queue-it
      By Queue-it+
      I've created a new post category "Success stories" with Custom Post type UI. (in order to have a different layout for a different post category - blog post one layout, success stories another layout).
      New category "success stories" are "detached" from all the other posts, so they have a different layout, but the problem is that all of the success stories are also having the same exact content.
      So whenever I edit content (e.g. change body text) on one of success story posts, it also changes the content (body text) for all other Success story category posts. 
       
      Question: Is there a way to retain this separate category with it's own layout, and have a different content for each individual post? I'm using Pagelins templates. 
       Thanks in advance.
    • Queue-it
      By Queue-it+
      Hi,
      Is is possible to have different layouts for different Post categories? We have Blog posts, News posts and Case studies that all are posts, but is it possible to differentiate their layouts?
      So far when I change a post layout it affects all Post type pages. Could it be done somehow with creating a separate template? 
      Examples below
      https://queue-it.com/news/
      https://queue-it.com/blog/
       
    • mzhafzah
      By mzhafzah
      Hello
      I am using DMS 2 theme and I want to create a 2 different links on my website; each link should take you to a different blog post category. Although the process is easy, yet I can not figure out how to give each category page a unique design of its own; Any change I make on any page is applied to the other (I'm aware of the universal elements like the header and footer and I a am not talking about these.)
      Since I am new to wordpress in general, I am not sure if my description is sufficient; apologies if it is not.
      TycoonJé
×