Exclude the Newest Recent Post from their Category After New post Publish old post should be in their category at Home Page
Exclude the Newest Recent Post from their Category After New post Publish old post should be in their category at Home Page
Exclude the Newest Recent Post from their Category After New post Publish old post should be in their category at Home Page
get_the_category() has a filter, get_the_categories, that will filter the categories. You can do something like this: add_filter( ‘get_the_categories’, ‘wpse426499_filter_categories’ ); /** * Filters the categories. * * @param WP_Term[] $categories An array of WP_Term (ie, category) objects. * @return WP_Term[] The filtered array of WP_Term objects. */ function wpse426499_filter_categories( $categories ) { $undesired_id = 2; … Read more
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