Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26892

CygnusH33L on "problems with WP_Query and my plugin"

$
0
0

Thanks for the reply Micah, I have tried what you suggested but was unable to get it working.
I have however managed to resolve it, this is how

function exclude_category($query) {
	if(!is_user_logged_in()) {
		if ($query->is_main_query()) {
			$cate = get_cat_id('private');
        		$query->set( 'cat', '-'.$cate );
    		}
	}
}
add_action( 'pre_get_posts', 'exclude_category' );

Viewing all articles
Browse latest Browse all 26892

Trending Articles