Try using has_term()
which accepts a term_name
, term_id
, or slug
to test again. You’ll need to pass the post_id
too, something like this:
global $post;
if( isset( $post ) && is_singular( 'my_custom_post_type' ) && has_term( 'my_custom_post_type_category', 'my_custom_taxonomy', $post->ID ) ) {
// Code Goes Here...
}
You may also be able to use has_category()
which work very similar but if I were a betting man I’d bet that that function would only work for the built-in Post Categories but still worth mentioning.
Related Posts:
- How do test if a post is a custom post type?
- Conditional for single-{post-type}.php
- is_singular() not working if called via callback function of admin-ajax.php
- functions.php conditional tag only for custom post type
- Exclude custom function content from certain pages
- Get template part based on custom taxonomy term
- If on term-page -> get the current term?
- custom post type upcoming post and past post
- changing default comment form arguments [duplicate]
- is_page_template not working as expected
- remove child post from custom post type archive
- if custom posts type exists and there are posts load script
- Need help targeting a custom post type with conditional tags
- Why would this IF statement not work? [closed]
- custom comments on specific post type
- Excluding custom post types
- Register widget only page is a singular of custom post type
- Is there a conditional tag to determine whether the post is _any_ custom post type?
- Conditional Query of Custom Post Type and custom taxonomy
- How to run filter only on custom post type edit screen
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Custom Post Conditional for Parent & Child Single.php?
- Conditional for a Single Post That Belongs to a Category?
- How to show only the most recent post on my custom post type archive?
- Move Genesis Single Page/Single Post Title
- How to check if post/page or taxonomy post is published by admin
- TinyMCE Buttons on Certain Post Type
- Display message if no posts in Custom Post Type loop
- Showing taxonomy terms on custom post type
- Check if custom post is a parent?
- Redirect to URL if x number of days passed
- comments hooks on custom post type
- Conditional Statements
- If custom taxonomy else conditional [closed]
- If tag exists, then echo once
- Show specific content on parent custom post type and all children
- Use conditionals with wp_enqueue_style to attach stylesheet according to post type displayed
- How can I check the rewrite slug of current post type listing page
- How to add custom PHP code in post header?
- $_SESSION Not working after X amount of page views
- conditional based upon the count of current user’s published custom posts
- Custom metabox fields not saving when limited to a certain CPT
- Can not hook into custom post type template with: is_page() conditional?
- Diffrent search templates for different post types
- Conditional Tags If Custom Post Parent & Child?
- Custom Post Query Combined with Conditional Tags
- Conditional statement checking two conditions for CPT and Custom Taxonomy [closed]
- strange conditional tag behaviour [duplicate]
- Custom post type is_singular condtional not working when managing sidebar display
- How to get current get_post_types name?
- How to rewrite URI of custom post type?
- How to get the custom post type from an archive page?
- Get term slug of current post
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- Ordering posts having multiple post-meta date fields
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Why is get_post_format() for “Standard” returns empty
- Get multiple custom type posts at once in edit.php?post_type request
- Disable revisions for a specific post type only?
- How to get the parent’s taxonomy?
- How do I redirect all 404 errors of a specific post type to another URL?
- Priority of Meta Box for Custom Post Type
- Replacing the title in admin list table
- template_redirect not working, apparently for no reason
- Adding paged query to custom URL rewrite
- Structure for projects and clients
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Search Custom Post Type Custom Fields
- Optimised Code for Pulling Taxonomy Posts
- How can I get the first 50% of all posts (within a custom post type)?
- get_terms showing all categories instead of the ones assigned to a specific post
- Group posts by custom post type
- Is using taxonomies the way to go here or would custom post types be better?
- Default post tab showing twice in admin bar
- Pre-selecting the category for a custom post type
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Extracting Address from Custom Post via Javascript for Google Maps API
- Custom Post Types — $args vs. labels array
- Can anyone clarify difference between archive-{posttype}.php, type-{posttype} and date.php?
- widget_posts_args not using the number of posts in widget
- Get current user id
- Add data to post edit page, when post is published
- How can deregister scripts for a certain custom post type?
- Custom posts – tag pagination
- Getting custom post types to properly display alphabetically
- One post auto attached to many another items
- Submit Custom Postypes from frontend
- How to display posts from a certain category in a bootstrap 5 carousel loop with multiple items?
- Define multiple prefixes for custom post type
- How to get custom post type with dynamic ID
- Query custom post type and custom field by URL parameters
- Querying, storing, and using data from 2 separate custom post types
- How to display data with pagaination on backend?
- Edit post meta direct from post.php?
- Load different template for CPT (in loop) in my plugin?
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Change post structure
- Permalinks for Custom Post Types and Taxonomies
- Group search results by post type, but having a unique heading for each section?