How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?

Question

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?

0
, , , , Ana Ban 11 years 2012-06-12T00:29:11-05:00 0 Answers 82 views 0

Leave an answer

Browse
Browse