I am using the the_post_navigation()
function in WordPress like this:
<?php the_post_navigation( array(
'prev_text' => __( 'Previous item'),
'next_text' => __( 'Next item'),
)); ?>
This navigation goes through all my posts, but I want to exclude the posts that contain the category 'footer'. How do I do this?
I have used this to let the page redirects itself when the single.php goes to a post with the category 'footer':
if(in_category('footer')){
$next_post = get_next_post();
$location = get_permalink( $next_post->ID );
wp_redirect( $location );
exit;
} else {}
(Works only when places above get_header();
. Not the most beautiful solution, but it works (only for next post unfortunately)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.