How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
I added the following to my functions.php:
add_action('pre_get_posts', 'keyl_get_emp_posts');
function keyl_get_emp_posts($query) {
if ($query-is_main_query())
$query-set('post_type', 'employee');
}
and so far it's effectively filtering out the search results. The default widgets Recent Posts and Recent Comments aren't budging, though. What gives?
Topic recent-posts pre-get-posts wp-query widgets comments Wordpress
Category Web