Skip to content

Snippet: Alter Any Theme Template Part via Callable Function or Custom File

// Example to override the Top Bar Content
// See Total/framework/template-parts.php for the array of template parts
add_filter( 'wpex_template_parts', function( $parts ) {
	$parts['topbar_content'] = function() {
		echo 'Replace the topbar content with this.';
	};
	return $parts;
} );

// Example to override blog entries for the homepage only
add_filter( 'wpex_template_parts', function( $parts ) {

    // Custom output for homepage blog entries
    if ( is_home() ) {
        $parts['blog_entry'] = function() {
            get_template_part( 'home-entry' ); // Now you can create a file named home-entry.php in your child theme to override the homepage entries
        };
    }

    return $parts;

} );
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