Load the widget based on CPT
-
Hi All,
Anyone experience using the widget logic? I tried to to load the widget based on specific post but not working.What I did is:
global $post;
if ( $post->post_type == ‘static_post’ // checks the post type of the post
&& is_single() // Checks if this is a single post
&& has_term( ‘326’, ‘community_cat’, $post->ID ) // Check if post has specific term
) {
// Do something if our condition is true
}static_post is the Custom Post Type, 326 is the ID of Child of Custom Taxonomy (term), and the community_cat is the main of the Custom Taxonomy.
Thanks for help
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Load the widget based on CPT’ is closed to new replies.