How to select category on if function

According to the documentation, transition_post_status action receives only 3 parameters ($old_status, $new_status, and $post). There is no $category_id parameter, but as post object is available for you, you are able to get post category using this post object. In your case, for the if statement, it’s better to use has_category() function where you can pass … Read more

How to put an array in is_category

Try: $mycategory = array(23, 33, 37); if( is_category( $mycategory ) ) { echo ‘yes’; } else { echo ‘no’; } is_category returns true if there are any matches. You could try this: … $term = get_term_by( ‘id’, $child, $taxonomy_name); if ( is_category( $term->term_id ) ) { $mycategory[] = $term->term_id; }

Add image to each podcast series (or category) in headless WordPress instance [closed]

I think it would be prudent to create a new custom taxonomy now named podcast in order to categorize your episodes separate from other content. Whether using a custom podcast taxonomy or generic categorys, taxonomies do not support attached media or featured images out of the box. You’ll likely need to store a media attachment … Read more

Automatically redirect a page to a category that share the same slug

Well you can just turn the code 180 degrees from the linked question and problem solved. Just kidding. I would start with getting the current page slug, using that slug search for a category that has that slug, if found, redirect to it add_action(‘template_redirect’, ‘bt_redirect_page_to_category’); function bt_redirect_page_to_category () { // if we are not in … Read more

Related Tags not in category

Very similar to what you do with tags. Retrieve IDs of categories for current post: $categories = get_the_category(); $cat_ids = array(); foreach($categories as $category) $cat_ids[] = $category->term_id; Then exclude them in query: ‘category__not_in’ => $cat_ids,

And/Or Category Query

Strange, that usage of category__and should be working. As for following logic I don’t think you can accomplish anything that complex with query parameters. There are several possible ways to deal with it that I can think of: simplify category structure and/or selection logic; modify raw SQL with posts_where filter; store selection criteria in post … Read more