exclude certain categories from the list at the end of the blog post
exclude certain categories from the list at the end of the blog post
exclude certain categories from the list at the end of the blog post
Exclude a category ID from the following function
How to exclude first 2 posts from a specific category for a custom post type archive page
$query = new WP_Query( array( ‘tag__not_in’ => array( 37, 47 ) ) ); tag_not_in id is not string, so you don’t need to quote the numbers. For Deep in Query check in here
Exclude pages by custom field (with yes/no) storing wrong data?
WP Recommended Table Exclusions?
To exclude a category from the home page, use the pre_get_posts action: function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘-1,-1347’ ); } } add_action( ‘pre_get_posts’, ‘exclude_category’ ); In this example, 1 and 1347 are the category IDs you’d like to exclude. Also see the Conditional Tags page for … Read more
As Geert pointed out, your current conditional will always be true. An if() construct needs to be fed an expression. You’re feeding it a valid array, so that’s true. Always. So far this is basic PHP, regardless of whether in a WP environment or not. As can be read in Chris_O’s comment if ( is_category(‘some-cat’) … Read more
Within the post loop you can do, $category = get_the_category(); if($category[0]->cat_name == “featured”) { //if first category in array is “featured”, get next category in line $name = $category[1]->cat_name; $cat_id = get_cat_ID( $name ); $link = get_category_link( $cat_id ); echo ‘<a href=”‘. esc_url( $link ) .'””>’. $name .'</a>’; } else { //get the first category … Read more
The method is similar, just exclude the author by prefixing the id with a minus sign: $wp_query_obj->set( ‘author’, ‘-1’ ); See WP_Query for a full list of query arguments.