{"id":6258771,"date":"2015-06-23T11:43:40","date_gmt":"2015-06-23T11:43:40","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/load-the-widget-based-on-cpt\/"},"modified":"2016-08-30T14:44:42","modified_gmt":"2016-08-30T14:44:42","slug":"load-the-widget-based-on-cpt","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/load-the-widget-based-on-cpt\/","title":{"rendered":"Load the widget based on CPT"},"content":{"rendered":"<p>Hi All,<br \/>\nAnyone experience using the widget logic? I tried to to load the widget based on specific post but not working.<\/p>\n<p>What I did is:<\/p>\n<p>global $post;<br \/>\nif ( $post-&gt;post_type == &#8216;static_post&#8217; \/\/ checks the post type of the post<br \/>\n     &amp;&amp; is_single() \/\/ Checks if this is a single post<br \/>\n     &amp;&amp; has_term( &#8216;326&#8217;, &#8216;community_cat&#8217;, $post-&gt;ID ) \/\/ Check if post has specific term<br \/>\n) {<br \/>\n    \/\/ Do something if our condition is true<br \/>\n}<\/p>\n<p>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.<\/p>\n<p>Thanks for help\ufeff<\/p>\n<p>https:\/\/wordpress.org\/plugins\/widget-logic\/<\/p>\n","protected":false},"template":"","class_list":["post-6258771","topic","type-topic","status-closed","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6258771","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6258771\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6258771"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}