Conditionally Enable or Disable Single Blog “Sections/Blocks”
/**
* Using the filter "wpex_blog_single_layout_blocks" you can enable/disable blocks from the front-end
* on single blog posts
*
* Default block ID's: featured_media, title, meta, post_series, the_content, post_tags, social_share, author_bio, related_posts_comments
*
* @link http://total.wpexplorer.com/docs/blog-single-post-builder/
*/
function my_blog_single_blocks( $blocks ) {
// Remove related items for all items except those in category "news"
if ( ! in_category( 'news' ) ) {
unset( $blocks['related'] );
}
// Return blocks
return $blocks;
}
add_filter( 'wpex_blog_single_layout_blocks', 'my_blog_single_blocks' );
All PHP snippets should be added via child theme's functions.php file or via a plugin (we recommend Code Snippets)