Exclude category when displaying all categories assigned to a post

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

hide particular category post from front page only [closed]

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

How to define category ID in an array?

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)