Snippets: Add/Remove “Blocks” (Sections) From Custom Post Type Posts

 * Any custom post type post layout can be altered via the wpex_{post_type}_single_blocks filter
 * which returns an array of the "blocks" or parts for the layout
 * that will be loaded from partials/cpt/cpt-single-{block}.php
 * Default array: array( 'media', 'title', 'meta', 'content', 'page-links', 'share', 'comments' );
 * You can use the filter to add, remove or re-order elements in the array as you wish.
 * Below is an example showing how to add a new block for a custom post type and remove one.
 * After adding your new blocks simply create a new file with the name "cpt-single-YOUR_KEY.php"
 * and place this file at partials/cpt/ in your child theme.
 * IMPORTANT: Make sure to change {post_type} with your post type name
 * IMPORTANT: Make sure to replace "YOUR_KEY" with the key given in the array (advertisement is the key for the block added below)
add_filter( 'wpex_{post_type}_single_blocks', function( $blocks ) {

    // Option 1: Add new block "advertisement" and create your cpt-single-advertisement.php file to add to your child theme
    $blocks['advertisement'] = __( 'My Advertisement', 'total' );

    // Option 2: Total 4.0+ only
    // Add new blocks with custom function output
    // Below is an example with an anonymous function but you can use custom functions as well ;)
    $blocks['custom_block'] = function() {

        echo 'my custom block';


    // Remove the featured image from this post type
    unset( $blocks['media'] );

    // Return blocks
    return $blocks;

} );
All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)