Skip to content

Snippet: Filter the Logo Image

Custom snippet showing how to conditionally modify the Total theme's header image logo. The following example shows how you can filter the logo to display a different image on the front page of your site (regular and retina). If you are not using a custom retina image you can ignore the second filter "totaltheme/header/logo/retina_image_id". And of course you will want to modify the code to fit your specific needs using your own conditional checks.

/**
 * Modify the header logo.
 */
add_filter( 'totaltheme/header/logo/image_id', function( $logo ) {
    if ( is_front_page() ) {
        $logo = 'YOUR CUSTOM IMAGE ATTACHMENT ID';
    }
    return $logo;
} );

/**
 * Modify the header retina logo.
 */
add_filter( 'totaltheme/header/logo/retina_image_id', function( $logo ) {
    if ( is_front_page() ) {
        $logo = 'YOUR CUSTOM IMAGE ATTACHMENT ID';
    }
    return $logo;
} );
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