user2306309 user2306309 -3 years ago 71
jQuery Question

Wordpress, excluding pages with pre_get_posts

i want to exclude all wordpress pages from all wordpress queries.

My idea to solve this problem was to set the posttype in

pre_get_posts


function meta_filter_posts( $query )
{
$query->set( 'post_type' => 'post' );
}

add_filter( 'pre_get_posts', 'meta_filter_posts' );


But it doesn't work. I get no results. Why?

Answer Source

The correct syntax is:

$query->set('post_type', 'post');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download