Skip to content

Total Theme: Add, override or insert Template after header with PHP

/**
 * Insert a Templatera template after the site header.
 *
 * @link https://totalwptheme.com/docs/snippets/insert-template-content-via-theme-hooks/
 */
add_action( 'wpex_hook_header_after', function() {
	$template = 100; // Change this to the templatera post ID
	echo do_shortcode( '[templatera id="' . $template . '"]' );
} );

Or if you do not use templatera but the total them internal template-system:

add_action( 'wpex_hook_header_after', function() {
	$template = 100; // Change this to the dynamic template post ID
	echo do_shortcode( '[wpex_template id="' . $template . '"]' );
} );

Override page template

add_filter( 'wpex_archive_template_id', function( $template_id ) {
    if ( is_category( 'news' ) ) {
    //if ( is_singular( 'book' ) ) { etc.
        $template_id = 2; // set a different template_id for the news category
    }
    return $template_id;
} );
/**
 * Override Header Builder Template ID
 *
 * @link https://totalwptheme.com/docs/snippets/header-builder-id/
 */
add_filter( 'wpex_header_builder_page_id', function( $id ) {
	if ( is_front_page() ) {
		$id = 'FRONT_PAGE_TEMPLATE_ID';
	}

	return $id;
} );

Override Header Template

/**
 * Override the page header with a custom template.
 *
 * @link https://totalwptheme.com/docs/snippets/page-header-template/
 */
add_filter( 'wpex_page_header_template_id', function( $id ) {
	return 'YOUR_TEMPLATE_ID';
} );

/**
 * Remove page header section from the customizer (optional if you are overriding the page header for the whole site).
 *
 * @link https://totalwptheme.com/docs/snippets/page-header-template/
 */
add_filter( 'wpex_customizer_sections', function( $sections ) {
    unset( $sections['wpex_page_header'] );
    return $sections;
} );

Dieser Beitrag hat 0 Kommentare

Schreibe einen Kommentar

Deine E-Mail wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

An den Anfang scrollen