我有一个函数,可以根据查看的类别设置posts\\u per\\u page选项。
我发现了一个我无法真正理解的错误:首先,这是我如何得到错误的:
function custom_posts_per_page($query) {
if ( !is_admin() && is_category(4)) {
// Leaving this empty or with content
}
}
add_filter( \'pre_get_posts\', \'custom_posts_per_page\' );
因此,如果WP\\u Debug变为true,并且当我访问一个不存在的类别时,我会在那里得到一个错误。所以如果我进去http://localhost/zz/category/uncategorized
没有问题,但如果我输入例如http://localhost/zz/category/aaaaaaaa
(类别AAAAAAA不存在),它正确进入404页,但抛出以下错误:Notice: Trying to get property of non-object in C:\\xampp\\htdocs\\zz\\wp-includes\\query.php on line 3420
Notice: Trying to get property of non-object in C:\\xampp\\htdocs\\zz\\wp-includes\\query.php on line 3422
Notice: Trying to get property of non-object in C:\\xampp\\htdocs\\zz\\wp-includes\\query.php on line 3424
怎么了?