Editing functions: the_post_navigation();
-
Am i missing some key understanding in how to make changes to some of the built in wordpress functions. I wanted to restrict the previous and next links on my site to only link to posts in the same category.
The basic function looks like this:
<?php the_post_navigation(); ?>If I split this into two functions I can set an option to TRUE so that the nav links only to same category:
<?php previous_post_link('%link', '%title', TRUE); ?> <?php next_post_link( '%link', '%title', TRUE ); ?>But when I do this I lose all the markup code around around the links, so at the end I have to replace all the divs and I get this:
<nav class="navigation post-navigation" role="navigation"> <h2 class="screen-reader-text">Post navigation</h2> <div class="nav-links"> <div class="nav-previous"> <?php previous_post_link('%link', '%title', TRUE); ?> </div> <div class="nav-next"> <?php next_post_link( '%link', '%title', TRUE ); ?> </div> </div> </nav>This seems like a pain in the backside to have to do everytime I want to make a small change – surely I am missing some simpler way of editing the original function? Note: I am using _s theme.
The topic ‘Editing functions: the_post_navigation();’ is closed to new replies.