由于WordPress 3.4.0,可以将参数过滤到查询中。
add_filter(\'widget_posts_args\', \'wpse_30124\');
function wpse_30124(){
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
);
}
更多信息
class-wp-widget-recent-posts.php