Skip to content

Snippet: Add New “Blocks” to the Blog Entry Layout

We recommend you check out the newer snippet here with inline output options.

This snippet can be used to add new "blocks" to the blog entry layout which you can enable via the Customizer if you are NOT using a dynamic template and then you can add a template file in your child theme to control the output of the block.

/**
 * Example function for adding new "blocks" to the blog entry layout manager.
 *
 * After adding your new blocks simply create a new file with the name "blog-entry-YOUR_KEY.php"
 * and place this file at partials/blog/ in your child theme. Make sure to replace "YOUR_KEY" with
 * the key given in the array.
 *
 * IMPORTANT: This module will be disabled by default, so you will have to go to the Customizer to enable it.
 *
 * Default blocks: The default blocks included are featured_media, title, meta, excerpt_content, readmore
 * If you want to show/hide blocks conditionally without affecting the Customizer settings you should use the 'totaltheme/blog/entry_blocks' hook instead which also allows you to display a custom output for your "block" without
 * creating a new template file!
 *
 */
add_filter( 'totaltheme/blog/entry_blocks/choices', function( $blocks ) {
    $blocks['advertisement'] = __( 'My Advertisement', 'textdomain' );
    return $blocks;
} );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top