{"id":4185,"date":"2021-08-05T13:56:41","date_gmt":"2021-08-05T05:56:41","guid":{"rendered":"https:\/\/conditionalblocks.com\/docs\/conditions\/posts-includes-cpt\/"},"modified":"2025-05-01T12:27:34","modified_gmt":"2025-05-01T04:27:34","slug":"posts","status":"publish","type":"docs","link":"https:\/\/conditionalblocks.com\/docs\/post\/posts\/","title":{"rendered":"Posts (Includes CPT)"},"content":{"rendered":"\n<p>Control the visibility of any WordPress Blocks if they appear on selected individual posts from any Post Type and CPT (<a href=\"https:\/\/kinsta.com\/blog\/wordpress-custom-post-types\/\" target=\"_blank\" rel=\"noreferrer noopener\">Custom Post Types<\/a>).<\/p>\n\n\n\n<p>This feature is especially helpful when creating content blocks across multiple pages using <strong>WordPress Full Site Editing<\/strong> or <strong>WordPress 5.8+ Block Widgets<\/strong>.<\/p>\n\n\n\n<p>You can use it today with Widget Areas such as Sidebars.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to change the visibilty of a block for specific post<\/h2>\n\n\n\n<p>As a creative example, we&#8217;ll use the new WordPress Block widgets in our shop sidebar. We want to create a unique block inside the sidebar that only appears on our Beanie. Firstly we&#8217;ll create the block inside the widget editor, then select the block. <\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"607\" data-id=\"4189\" src=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-wordpress-block-widgets-on-other-pages-1024x607.jpg\" alt=\"Screenshot showing that the conditional block is not showing on other posts\" class=\"wp-image-4189\" srcset=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-wordpress-block-widgets-on-other-pages-1024x607.jpg 1024w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-wordpress-block-widgets-on-other-pages-300x178.jpg 300w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-wordpress-block-widgets-on-other-pages-768x455.jpg 768w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-wordpress-block-widgets-on-other-pages.jpg 1365w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Default Sidebar (&#8220;Product Investigation&#8221; Block is hidden)<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"628\" data-id=\"4188\" src=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-block-widget-wordpress-after-1024x628.jpg\" alt=\"Showing how conditional content looks using WordPress Block Widgets\" class=\"wp-image-4188\" srcset=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-block-widget-wordpress-after-1024x628.jpg 1024w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-block-widget-wordpress-after-300x184.jpg 300w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-block-widget-wordpress-after-768x471.jpg 768w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/conditional-block-widget-wordpress-after.jpg 1400w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Conditions are triggered and our &#8220;Product Investigation&#8221; block is visible in the sidebar<\/figcaption><\/figure>\n<\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click Configure Conditions.<\/li>\n\n\n\n<li>Add the Posts (Includes CPT) condition.<\/li>\n\n\n\n<li>Select the Post Type of your post. (Post, Page, Product, etc..).<\/li>\n\n\n\n<li>Select your specifics posts by searching for the name of the post.<\/li>\n\n\n\n<li>Choose if the block should be visible or hidden using the Block Action.<\/li>\n\n\n\n<li>Save then widgets &#8211; That&#8217;s it!<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Adding the &#8220;post&#8221; condition to a block<\/h3>\n\n\n\n<p>You can add conditions to any block by selecting the block and find the &#8220;Configure conditions&#8221; button in the sidebar of the WordPress editor. In our example, we are using a Group block to group a Header and Paragraph block together. Group blocks make it easier to manage conditions and apply background colors to the group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1758\" height=\"895\" src=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/creating-a-block-widget.png\" alt=\"Screenshot of creating a block widget for sidebars in WordPress 5.8+\" class=\"wp-image-4190\" srcset=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/creating-a-block-widget.png 1758w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/creating-a-block-widget-300x153.png 300w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/creating-a-block-widget-1024x521.png 1024w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/creating-a-block-widget-768x391.png 768w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/creating-a-block-widget-1536x782.png 1536w\" sizes=\"(max-width: 1758px) 100vw, 1758px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Configuring the Posts Condition <\/h3>\n\n\n\n<p>The Post Condition feature requires you to firstly choose the <strong>Post Type<\/strong> and <strong>then the specific Posts<\/strong>. WordPress content is generally built as different Post Types. <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Posts<\/li>\n\n\n\n<li>Pages<\/li>\n\n\n\n<li>Custom Post Types (e.g Products in WooCommerce)<\/li>\n<\/ul>\n\n\n\n<p>WooCommerce Products are created as a custom Post Type. In our example we are using products, therefore, we&#8217;ll select &#8220;Products&#8221;.<\/p>\n\n\n\n<p>Next, we can search for the specific posts that belong to the selected Post Type. In our case, we&#8217;re searching for a &#8220;beanie&#8221;. <\/p>\n\n\n\n<p><strong>TIP<\/strong>: You can select multiple posts. The block action will trigger if the current post matches any of the selected posts.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1755\" height=\"863\" src=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/select-posts-condition-for-wdiget.png\" alt=\"Adding the setting to control the visibility of a WordPress Block Widget\" class=\"wp-image-4191\" srcset=\"https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/select-posts-condition-for-wdiget.png 1755w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/select-posts-condition-for-wdiget-300x148.png 300w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/select-posts-condition-for-wdiget-1024x504.png 1024w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/select-posts-condition-for-wdiget-768x378.png 768w, https:\/\/conditionalblocks.com\/wp-content\/uploads\/2021\/08\/select-posts-condition-for-wdiget-1536x755.png 1536w\" sizes=\"(max-width: 1755px) 100vw, 1755px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">That&#8217;s it!<\/h2>\n\n\n\n<p>You can combine the Post condition with any of the other features in Conditional Blocks to create even more unique content.<\/p>\n","protected":false},"featured_media":0,"parent":8490,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","nav_title":"","positive":"","negative":"","footnotes":""},"docs_category":[],"class_list":["post-4185","docs","type-docs","status-publish","hentry"],"blocksy_meta":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"docspress_archive":false,"1536x1536":false,"2048x2048":false,"sl-small":false,"sl-large":false},"uagb_author_info":{"display_name":"Morgan","author_link":"https:\/\/conditionalblocks.com\/author\/"},"uagb_comment_info":0,"uagb_excerpt":"Control the visibility of any WordPress Blocks if they appear on selected individual posts from any Post Type and CPT (Custom Post Types). This feature is especially helpful when creating content blocks across multiple pages using WordPress Full Site Editing or WordPress 5.8+ Block Widgets. You can use it today with Widget Areas such as&hellip;","_links":{"self":[{"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/docs\/4185","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/comments?post=4185"}],"version-history":[{"count":4,"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/docs\/4185\/revisions"}],"predecessor-version":[{"id":11014,"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/docs\/4185\/revisions\/11014"}],"up":[{"embeddable":true,"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/docs\/8490"}],"wp:attachment":[{"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/media?parent=4185"}],"wp:term":[{"taxonomy":"docs_category","embeddable":true,"href":"https:\/\/conditionalblocks.com\/wp-json\/wp\/v2\/docs_category?post=4185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}