如题,5.7.1版本里的function wpcom_load_posts() 函数有问题,导致首页的最新资讯里仍然显示已经设置为不显示的分类。跟5.4.0版本的代码对比了一下,发现5.7.1的代码做了一点修改,导致这种问题的发生。改为5.4.0版本的代码即可正常。
问题代码如下:
5.7.1版本
$exclude = isset($_POST['exclude']) ? $_POST['exclude'] : '';
if($exclude) $exclude = explode(',', $exclude);
$exclude = $exclude ? $exclude : array();
$arg = array(
'posts_per_page' => $per_page,
'paged' => $page,
'ignore_sticky_posts' => 0,
'post_type' => 'post',
'post_status' => array( 'publish' ),
'category__not_in' => $exclude
);
$posts = new WP_Query($arg);
5.4.0版本
global $options;
$exclude = isset($_POST['exclude']) ? $_POST['exclude'] : '';
if($exclude) $exclude = explode(',', $exclude);
$exclude = $exclude ? $exclude : $options['newest_exclude'];
$arg = array(
'posts_per_page' => $per_page,
'paged' => $page,
'ignore_sticky_posts' => 0,
'post_type' => 'post',
'post_status' => array( 'publish' ),
'category__not_in' => $exclude ? $exclude : array()
);
$posts = new WP_Query($arg);
折腾老半天才找出来,排除了插件兼容性等因素之后,最终意识到应该是代码的问题,多亏还保留了一份以前的版本:(:(:(:(