如題,5.7.1版本里的function wpcom_load_posts() 函數(shù)有問(wèn)題,導(dǎo)致首頁(yè)的最新資訊里仍然顯示已經(jīng)設(shè)置為不顯示的分類(lèi)。跟5.4.0版本的代碼對(duì)比了一下,發(fā)現(xiàn)5.7.1的代碼做了一點(diǎn)修改,導(dǎo)致這種問(wèn)題的發(fā)生。改為5.4.0版本的代碼即可正常。
問(wèn)題代碼如下:
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);
折騰老半天才找出來(lái),排除了插件兼容性等因素之后,最終意識(shí)到應(yīng)該是代碼的問(wèn)題,多虧還保留了一份以前的版本:(:(:(:(