Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #224614

    Is there a way to have a different logo on each page?
    We have a site that has a different colour logo for each part of the business, and struggling to make this feature work.

    #224782

    Christian
    Moderator

    Hey there,

    That is technically possible however, that would require custom development which falls outside the scope of our support. Basically, you would need to modify _brand.php located in wp-content\themes\x\framework\views\global. To give you an idea, you need to wrap the code

    <a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
      <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
    </a>
    

    in a WordPress conditional tag like

    <?php if ( is_page( 693 ) ) : ?>
    <a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
      <img src="URL OF YOUR OTHER LOGO">
    </a>
    <?php else : ?>
    <a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
      <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
    </a>
    <?php endif; ?>

    That code will output a different logo in page with ID of 693. If not, it’ll use the default image from the Customizer. The code is tested and working on my test install however, this should not be considered as complete or the only solution.

    You might want to contact our trusted partners who caters X setup and customization needs. Please see https://theme.co/x/member/custom-development/.

    Thanks.

    #224916

    Thank you! I may do this.

    #224984

    Darshana
    Moderator

    Let us know how it goes 🙂

    #226299

    Hi!

    Success! Thank you so much for that bit of code. I have to google how to have more than one condition, but I worked it out and… well, I’m very excited about it – probably more excited than a person should be.

    The site isn’t live to the wide world yet, but I’ll post a link when it is!

    #226436

    Rad
    Moderator

    Congratulations! 😉 Glad we could help you!

    #906557

    blissmarketing
    Participant

    Hello

    Great post

    I am currently looking to do this – keeping main logo same then we have 3 pages all with 3 different logos

    Will this work with three or is this just to change one?

    Jen xxxx

    #906577

    blissmarketing
    Participant

    it works perfectly for the one page – any updates on how you did it for the other pages – i have two more that need logos changing xxx

    #907339

    Rue Nel
    Moderator

    Hello There,

    Thanks for updating this thread! You can modify the code above using else if statement so that you can have a different logo in any page you want in your site.

    <?php if (is_page('#') ) : ?>
       // your logo here
    <?php elseif (is_page('#') ) : ?>
       // your logo here
    <?php elseif (is_page('#') ) ?>
       // your logo here
    <?php elseif (is_page('#') ) ?>
       // your logo here
    <?php else : ?>
       // your default logo here
    <?php endif; ?>

    Hope this helps.

    #910000

    blissmarketing
    Participant

    hey – thanks for your reply – i added it in but then the whole site went and it was just a gold background

    How can I fix this 🙁

    #910259

    Christopher
    Moderator

    Hi there,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Thanks.

    #1150828

    yesmedia
    Participant

    Can you add a example of the _brand.php file modified for 5 diferentes logos in 5 diferentes pages?

    I’ve been trying many differents ways but I still get a errors on the systansis.

    Thank you I will appreciated.

    #1150908

    Darshana
    Moderator

    Hi there,

    Let’s try this complete example.

    
    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_BRAND.PHP
    // -----------------------------------------------------------------------------
    // Outputs the brand.
    // =============================================================================
    
    $site_name        = get_bloginfo( 'name' );
    $site_description = get_bloginfo( 'description' );
    $logo             = x_make_protocol_relative( x_get_option( 'x_logo' ) );
    $site_logo        = '<img src="' . $logo . '" alt="' . $site_description . '">';
    
    ?>
    
    <?php echo ( is_front_page() ) ? '<h1 class="visually-hidden">' . $site_name . '</h1>' : ''; ?>
    
    <?php if (is_page('131') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="http://seeklogo.com/images/V/vietjet-aviation-logo-A823494846-seeklogo.com.png">
    	</a>
    <?php elseif (is_page('106') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="http://www.lodhagroup.com/corporate/media/images/logo.jpg">
    	</a>
    <?php elseif (is_page('about-us') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="http://www.getzcope.com/press/logos/zcope_web_rgb_small.jpg">
    	</a>
    <?php elseif (is_page('contact') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="https://upload.wikimedia.org/wikipedia/en/5/5a/Total_Giving_Logo.png">
    	</a>
    <?php else : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
    	</a>
    <?php endif; ?>
    

    You can locate the Post/Page IDs as follows (https://community.theme.co/kb/how-to-locate-post-ids/). Also you can add page slugs as defined in the above example, for example (‘about-us’).

    Hope that helps.

    #1291283

    Free Chapel
    Participant

    Good day

    First, let’s acknowledge and thank the fine folks at Themeco for assisting everyone with this. It’s definitely beyond the scope of support yet they stuck with everyone to solve their problems. That is AWESOME support and AWESOME people. 🙂

    I want to contribute because the way we use X and WordPress is to mask pages as one-page sites based upon location. Therefore, we would need a special logo not just for each location’s page but also any children it possesses.

    In functions.php you can create a child checker (heh):

    
    function is_parentchild( $pid ) {
        global $post;
     
        if ( is_page($pid) )
            return true;
     
        $anc = get_post_ancestors( $post->ID );
        foreach ( $anc as $ancestor ) {
            if( is_page() && $ancestor == $pid ) {
                return true;
            }
        }
        
        return false;
    }
    

    So here we are using the WordPress function get_post_ancestors ( https://codex.wordpress.org/Function_Reference/get_post_ancestors ) to check for the page we are currently visiting to see if it matches the ID given and also to check any possible children to see if they belong to that page.

    Use: In your _brand.php file you will want to call the function is_parentchild(‘ID’) where ID is the page ID you are checking. So for example:

    
    <?php
    
    // =============================================================================
    // VIEWS/GLOBAL/_BRAND.PHP
    // -----------------------------------------------------------------------------
    // Outputs the brand.
    // =============================================================================
    
    $site_name        = get_bloginfo( 'name' );
    $site_description = get_bloginfo( 'description' );
    $logo             = x_make_protocol_relative( x_get_option( 'x_logo' ) );
    $site_logo        = '<img src="' . $logo . '" alt="' . $site_description . '">';
    
    ?>
    
    <?php echo ( is_front_page() ) ? '<h1 class="visually-hidden">' . $site_name . '</h1>' : ''; ?>
    
    <?php if (is_parentchild('131') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="http://seeklogo.com/images/V/vietjet-aviation-logo-A823494846-seeklogo.com.png">
    	</a>
    <?php elseif (is_parentchild('106') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="http://www.lodhagroup.com/corporate/media/images/logo.jpg">
    	</a>
    <?php elseif (is_parentchild('about-us') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="http://www.getzcope.com/press/logos/zcope_web_rgb_small.jpg">
    	</a>
    <?php elseif (is_parentchild('contact') ) : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <img src="https://upload.wikimedia.org/wikipedia/en/5/5a/Total_Giving_Logo.png">
    	</a>
    <?php else : ?>
    	<a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
    	  <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
    	</a>
    <?php endif; ?>
    

    This will allow you to have a custom logo for specified page in addition to any of that page’s subpages (or children) as well.

    We hope that helps, and as always I am sure the code in _base.php can be refined further.

    Safe and Merry Holidays to all

    Jeff

    #1291351

    Lely
    Moderator

    Hello Jeff,

    You’re welcome and thank you for sharing your this code. I am sure this will help others as well.

    Cheers!