Call function on a single page

Assuming your function runs generally, to limit it to a specific page use if( is_page( 2094 ) ) { add_filter(“sjb_job_location_filter_args”,”exclude_jobs_locations_uk”); } The location of the function definition doesn’t matter. P.S. Regarding excluding categories . . . yeah, we’d need to know a lot more about what’s going on with the called (plugin?) function

Exclude a ‘portfolio’ custom category?

Please take a look at this example; $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, ‘field’ => ‘id’, ‘terms’ => array( 103, 115, 206 ), ‘operator’ => ‘NOT IN’ //you must set the … Read more

Cannot exclude particular post from loop of custom post type

Something like this should work from your functions file as long as you use the correct conditional tag for your CPT archive: function exclude_single_post_cpt($query) { if (is_post_type_archive(‘event’) && $query->is_main_query() && !is_admin() ) { $query->set(‘post__not_in’, array(1646)); } } add_action(‘pre_get_posts’, ‘exclude_single_post_cpt’);

show 10 most recent custom post types excluding the one(s) from specific custom taxonomy

Firstly, your tax query is a little jumbled. The first nested array should actually be at the ‘root’ of your query_posts() argument, with tax_query as a key among them; array( ‘post_type’ => ‘review’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 10, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘reviewcats’, ‘terms’ => array( ‘featured’ ), ‘field’ … Read more

Exclude admin from the top commenters list [duplicate]

Assuming the comment_author is a User ID, try: if(user_can($result->comment_author,’manage_options’)){ $output .= “<li>”.(($result->comment_author_url) ? “<a href=””.$result->comment_author_url.””>” : “”).$result->comment_author.(($result->comment_author_url) ? “</a>” : “”).” (“.$result->comments_count.”)</li>”; } If not, one can use get_comment, and select the comment_ID in the SQL statement. You can then use the object returned to grab the user ID of the comments author, and do … Read more

How to have a category not show up in query post with page panigation?

When using cat in the query you need to specify the category id not name. Try this. <?php $gallery = get_cat_id(‘gallery’); $shirts = get_cat_id(‘shirts’); $hoodies = get_cat_id(‘hoodies’); $excluded_cats=”-“.$gallery.’,-‘.$shirts.’,-‘.$hoodies; $limit = 5; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; query_posts( ‘cat=”.$excluded_cats.”&showposts=” . $limit . “&paged=’ . $paged ); ?>

Exclude Category From Home Page, Display Posts on It’s Own Page?

Rather than performing a separate query, to exclude a category (or any other taxonomy) term, you can hook into pre_get_posts: add_action(‘pre_get_posts’, ‘wpse41820_exclude_cat_from_front_page’); function wpse41820_exclude_cat_from_front_page( $query ){ if( $query->is_main_query() && is_front_page() ){ $tax_query = array(array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( 57 ), ‘operator’ => ‘NOT IN’ )); $query->set(‘tax_query’,$tax_query); } return $query; } … Read more