唯一的方法是在最近使用过滤器
从…起developer.wordpress.org WP\\u Widget\\u最近发布的帖子::Widget
$r = new WP_Query( apply_filters( \'widget_posts_args\', array(
\'posts_per_page\' => $number,
\'no_found_rows\' => true,
\'post_status\' => \'publish\',
\'ignore_sticky_posts\' => true
) ) );
最好的方法是,在前端提交的帖子中添加一个类别。
add_filter(\'widget_posts_args\', \'wpse_244383\');
function wpse_244383(){
return array(
\'posts_per_page\' => $number,
\'no_found_rows\' => true,
\'post_status\' => \'publish\',
\'ignore_sticky_posts\' => true,
\'cat\' => \'-12\' // term_id of the category you want to exclude
);
}