where I find the file single.php
I have to modify previous\next_post_link – get_the_post_navigation
]]>In my example the category I want to use is the “News” category which has a “category&tag_ID=16”.
I’ve read the wordpress Codex about this function here but am still not sure how to edit the parameters within the function so it only shows previous and next posts from a specific category.
NB. The posts on this website often use multiple categories but as explained earlier, the “news” category (16) is the one I’m looking to use.
Currently the code I am using is as follows:
<div class="posts_navigation_single">
<div class="posts_prev_single">
<?php previous_post_link(); ?>
</div>
<div class="posts_next_single">
<?php next_post_link(); ?>
</div>
</div>
I’d very much appreciate any help in the above subject.
Many thanks
]]>I am using “previous_post_link” and “next_post_link” & option “TRUE” set to output Prev and Next post title work within the same category. However, I have encountered one little problem under the following circumstance.
1. Parent category “Noodle” and 3 child categories underneath “Pasta”, “Udon” and “Ramen”
2. Those 3 categories have many post and at the end of each single page, I have set previous and next post_link.
3. I want to see prev and next title link from the same category. For example. if the post is from “Pasta” category, prev and next post should only output within the “Pasta category” not from “Udon” or “Ramen”.
4. previous and next post_link work fine in the way I want if I doesn’t select parent category “Noodle” but only “Pasta” before publishing.
The problem is that because all the posts over 1000 have parent category “Noodle” selected, previous and next post_link output prev and next titles from all the Noodle category which has mixture of 3 different child categories “Udon, Pasta and Ramen”…
In other words, I want to output prev and next title links from the closest category (not parents).
It would be great if you could give me advise to avoid this situation without unselecting parent category “Noodle” one post by another.
I hope my explanation makes sense.
Thank you.
Palmtree
For example: I restrict it in_same_term, but now if there is no previous or next post it not display any link (because it is a last post in the category).
I need to display link form any post in the same term or started over the cycle.
So always to have next or previous link, never only one link?
Thank you for help.
]]>For example on a product page I would like to go to the next product that was the same type and brand. Nike and T-shirt for example.
This is the code I am using at the moment but it is obviously just using one of the custom taxonomies
<?php previous_post_link( '%link', 'Previous Rug', TRUE, ' ', 'collection' ); ?>
next_post_link(‘%link’, ‘ <span class=”meta-nav”>«</span>’, TRUE)
I expect to always navigate to the next post in category 5, but I’m getting posts from other categories and I can’t figure out why this isn’t working after reading the documentation on this function.
Thanks for any help,
C
You’ll see the template tags between line 36 and 39. I’m not sure why the links aren’t showing up. I’m using the exact same code on a different site and it’s working perfectly.
Help?
]]>previous_post_link()
inside of a function. I also tried assigning the output to a string variable and using that.
function prevnext( $content ) {
$content .= '<div>' . previous_post_link() . '-' . next_post_link() . '</div>';
return $content;
}
add_action( 'the_content', 'prevnext', 4 );
I get the hyphen – but not the links. Substituting another string variable also prints to the screen. I can use previous_post_link()
in the page template and it works fine. What am I not doing right?
Post preview in the “Customize” function of the backend shows “last post / next post” links on the bottom of each post as intended. However, when I visit they page from external, the links are not shown underneath the posts… https://www.bastianmathes.com/2016/01/3-toolboxes-to-up-your-strategy-game/.
Any ideas?
Thanks very much.
Bastian