Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 按类别从_post_导航()中排除帖子_Php_Wordpress - Fatal编程技术网

Php 按类别从_post_导航()中排除帖子

Php 按类别从_post_导航()中排除帖子,php,wordpress,Php,Wordpress,我使用WordPress中的发布导航()函数,如下所示: <?php the_post_navigation( array( 'prev_text' => __( 'Previous item'), 'next_text' => __( 'Next item'), )); ?> 此导航浏览我的所有帖子,但我想排除包含“footer”类别的帖子。如何做到这一点?当single.php转到具有“footer”类别的帖子时,我使用此选项让页面自动重定向:

我使用WordPress中的
发布导航()
函数,如下所示:

<?php the_post_navigation( array(
    'prev_text' => __( 'Previous item'),
    'next_text' => __( 'Next item'),
)); ?>


此导航浏览我的所有帖子,但我想排除包含“footer”类别的帖子。如何做到这一点?

当single.php转到具有“footer”类别的帖子时,我使用此选项让页面自动重定向:

 if(in_category('footer')){
    $next_post = get_next_post();
    $location = get_permalink( $next_post->ID );
    wp_redirect( $location );
    exit;
 } else {}
(仅当放置在
get_header();
上方时有效。
这不是最漂亮的解决方案,但它可以工作(不幸的是,只适用于下一篇文章)

当single.php转到具有“footer”类别的文章时,我使用它让页面重定向自己:

 if(in_category('footer')){
    $next_post = get_next_post();
    $location = get_permalink( $next_post->ID );
    wp_redirect( $location );
    exit;
 } else {}
(仅当放置在
get_header();
上方时有效。
虽然不是最漂亮的解决方案,但它确实有效(不幸的是,它只适用于下一篇文章)

$prevPost=get_nexture_post(false,'30,31,32410',true);检查此项好,获取上一篇文章不是问题。问题是此函数在加载页面时初始化。我必须找到一种方法,使其能够识别何时必须转到上一篇文章,何时必须转到下一篇文章。$prevPost=获取相邻文章(false,'30,31,32410',true);检查此项好的,获取上一篇文章不是问题。问题是此函数在加载页面时初始化。我必须找到一种方法,使其能够识别何时必须转到上一篇文章以及何时必须转到下一篇文章。