in_category
takes 2 parameters, the first being the categories to check, and the second being the post ID.
If we look at the official documentation on wordpress.org we can see these are the parameters that this function can accept:
in_category( int|string|int[]|string[] $category, int|object $post = null )
Taken from: https://developer.wordpress.org/reference/functions/in_category/
We can also see in the official documentation for that function an example of checking more than one category by using an array:
if ( in_category( [ 'Tropical Birds', 'small-mammals' ] ) {
Related Posts:
- How to get current_cat in navbar, in single post
- How can I get posts in a subcategory to display on it’s parent categories archive page?
- Custom category order with get_categories
- Custom sidebar category listing?
- Auto add taxonomy if post has category
- Show posts on a page based on a category and tag(s)
- Query posts by category AND custom field, then ORDERBY another custom field – help!
- How to add “Read More…” link in twentytwenty
- how to get the categories for a single product in a hierarchical way
- Automatically check parents (in a taxonomy) when child is selected
- Category selectable homepage
- How to change the category url jusy show /category/%category_id% in wordpress?
- How can I create a permalink with two categories, with the order based on the parent category?
- How do I list custom taxonomy terms with the links?
- Get whole linked with wp_list_pages
- Adding Multiple “Parents” in get_categories
- How to setup a membership system in WordPress?
- Make the home page template my archive/category page template without code duplication
- Create Miltiple Category Base
- Is it possible to edit a wordpress category with Gutenberg?
- How to show related post with category DESC (ASC) IDs of ID current post
- Hide entry-header for a specific category
- How can I add category variable inside posts?
- Post thats in Two Categories, only want to display name for one
- woocommerce display product category on checkout page [closed]
- Prevent posts from being published if the ‘Uncategorized’-category or no category is selected
- Show last child Child category instead of first child category on page
- wordpress categories narrow down results
- Modifying posts based on category in TwentyTwentyTwo theme
- Best Practices for Regression Testing WordPress Websites?
- Custom Walker: how to get ID in function start_lvl
- What is true chmod for WordPress?
- wp_trim_words() does not trim the_content() in WordPress
- How can I create an alternative home page?
- Gallery Shortcode: using link attribute to link to a specific image size
- get_theme_mod(); returns nothing
- Add default content to post (for specific category)
- Limit comments displayed on basis of user_id
- Find and replace domain name on the fly?
- What is the most idiomatic way to let clients edit phrases in HTML?
- How to Register and Display Widget for Custom taxonomy
- How to change “Dashboard” text in wordpress
- Hide post meta data on a specific category
- Image Editor does not affect custom sizes!
- How to access my php page in wordpress
- How to display post title & excerpt when mouse hovers on an image?
- Use a wordpress page to display a certain category
- How to fix the IE9/WordPress Twenty Ten Header Image Display Problem?
- Automatically add image caption with values from a post parent field?
- Search result page redirect ex.com/?s=searchterms to ex.com/searchterms
- Add styles with wp_add_inline_style only if modifications exist wp_add_inline_style
- Add custom field to woocommerce variations [closed]
- How would you implement a CTA infront of a videoplayer? [closed]
- How can I get the custom post type assigned to a current custom taxonomy for query?
- $wpdb->replace: WHERE?
- Unable to edit the “customize” section and the “widget” section is populating unknown code
- Can’t receive $args[ ] to my custom widget
- Can I create my own custom Attachment Display Setting?
- What WordPress Hook Is Used Before Signup Data is Saved?
- One WordPress install for main site at domain.com and blog at blog.domain.com?
- How to locate where an element is generated?
- Combine two conditions in one statement syntax [closed]
- Is there a way to add a new value into a stored custom field value?
- Custom Loop Query For Search Page
- spaces in a text
- Customizing Users in Admin Area
- Good way to customize admin CSS?
- Multiple selection for wordpress widget
- Add table to WordPress database
- get_delete_post_link( $post->ID ) is blank when logged in as “subscriber”
- Menu not appearing in custom theme
- How can i display custom menu in sidebar?
- Custom select query two tables by a meta key
- How to redirect the home page to a custom page?
- How to Add Additional Search Button?
- WordPress pagination with custom post type?
- How to replace blog page url with subdomain at all places, even in xml sitemap?
- Embed Latest Track (Dynamic Updating) SoundCloud
- website is not loading home page (moving from one server to another server)
- Gender based user avatar
- Javascript Tooltip not fully working on my wordpress page
- How to submit form data in the same page in WordPress without reloading the page?
- bulk generate wp taxonomy tags from wp title with self php script
- Translate site in own text-language [closed]
- Pull A Single Post Prior To Running wp_query
- Showing the project type in HREF
- Build custom pdf from users choices
- Show Header When Not In Iframe
- Changing a setting in the wp-admin/customize.php reverts CSS styles to parent theme [closed]
- Confused about customising widgets
- Create a folder if it doesn’t already exist
- Changes in comments.php in the child theme does not show up on the site
- how to modify request to get_template_part()?
- List all authors by matching custom meta data on a category page
- Getting Custom Field value in WP_Query
- Adding Custom HTML/CSS/JS code in specific page
- Custom template not working for existing pages [closed]
- Loop display only 5 posts
- Help needed renaming custom post
- A Voting system for a pageants