Tag Info

New answers tagged


If I understand you correctly you're not looking for the wp_search_stopwords filter type of solution. So here's a modification of the great answer by @kaiser that you referred to: /** * Exclude array of words from all search queries in the front-end * * Modification of http://wordpress.stackexchange.com/a/41100/26350 by @kaiser */ add_filter( ...


In your functions.php file, use pre_get_posts and swap out the -1 in the following code with the category I.D you want to exclude from your posts page. function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1' ); } } add_action( 'pre_get_posts', 'exclude_category' ); ...


Use the parameters cat or category__not_in: $query = new WP_Query( 'cat=-1234' ); The minus means to exclude, the ID is used. $query = new WP_Query( array( 'category__not_in' => array( 1234 ) ) ); Uses the ID too. Use get_cat_ID() to get the ID by name or get_category_by_slug() to do it by slug, the latter returns an object though.

Top 50 recent answers are included