Show category from “Next post” and “Previous post”
Question
I would like the middle category (CatSon) to be shown by replacing to replace the words PREVIOUS and NEXT in previous_post_link
and next_post_link
In my case, each post is tagged in a category with 2 ancestors. Example: CatFather, CatSon and CatGrandson
This is the function I have from theme TwentyFourteen:
function twentyfourteen_post_nav() {
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'twentyfourteen' ); ?></h1>
<div class="nav-links">
<?php
if ( is_attachment() ) :
previous_post_link( '%link', __( '<span class="meta-nav">Published In</span>%title', 'twentyfourteen' ) );
else :
previous_post_link( '%link', __( '<span class="meta-nav">Previous Post</span>%title', 'twentyfourteen' ) );
next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) );
endif;
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;
0
categories, next-post-link, previous-post-link
3 years
2019-10-31T12:28:36-05:00
2019-10-31T12:28:36-05:00 0 Answers
85 views
0
Leave an answer