Exclude Post Format from Next/Previous Posts
-
I am trying to modify my previous/next post navigation on a custom post type page. I want to exclude the “Link” post formats from the navigation, so only standard posts are included, but I can’t seem to get it to work. It works perfectly otherwise.
Here is my code:
<?php // Previous/next post navigation. $next_post = get_next_post(); $previous_post = get_previous_post(); the_post_navigation( array( 'next_text' => get_the_post_thumbnail($next_post->ID,'thumbnail') . '<h4>' . __( 'Next Project:') . '</h4> ' . '<h3>%title</h3>', 'prev_text' => get_the_post_thumbnail($previous_post->ID,'thumbnail') . '<h4>' . __( 'Previous Project:') . '</h4>' . '<h3>%title</h3>', ) ); ?>
I have also tried using the previous/next_post_link query, this one shows nothing at all when the in_same_term variable is set to true:
<?php previous_post_link( '%link', 'Previous project: %title', TRUE, '', 'post_format' ); ?> <?php next_post_link( '%link', 'Next project: %title', TRUE, '', 'post_format' ); ?>
Anyone have any suggestions? This is beyond frustrating.
- The topic ‘Exclude Post Format from Next/Previous Posts’ is closed to new replies.