Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #905058
    chagemeier
    Participant

    I have seen posts on the net about this but I wanted to get a “supported” answer for how to be able to specify a specific logo by category. So if a category is one of a group the theme displays one logo but if the page/post is in a different category the theme displays a different logo.

    Thanks,
    Curt

    #905848
    Thai
    Moderator

    Hi Curt,

    Regretfully, at this time I am not entirely certain what it is you would like to accomplish based on the information given in your post. If you wouldn’t mind providing us with a little more clarification on what it is you’re wanting to do (a link to a similar example site would be very helpful, or perhaps some screenshots), we’ll be happy to provide you with a response once we have a better understanding of the situation.

    #911764
    chagemeier
    Participant

    I’m sorry reading my request back I realize that it was very vague.
    What I am trying to ask is how to change the header logo by the category of the post.
    For example if the post a certain category display header logo x, if it is not display header logo y.
    I think this is what I am asking but so many posts have wildly different answers.

    https://wordpress.org/support/topic/need-help-with-a-code-for-a-different-logo-for-each-category

    Thanks,
    Curt

    #912128
    Lely
    Moderator

    Hello Curt,

    Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

    Then copy _brand.php from wp-content\themes\x\framework\views\global to wp-content\themes\x-child\framework\views\global. Open the copied file and replace the entire code with the following:

    <?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>' : ''; ?>
    
    <a href="<?php echo home_url( '/' ); ?>" class="<?php x_brand_class(); ?>" title="<?php echo $site_description; ?>">
      <?php if( is_category(8)){ ?>
      <?php echo '<img src="http://virtualhost.dev/latestwp/wp-content/uploads/2016/05/different-logo.jpg" alt="' . $site_description . '">'; ?>
      <?php }else{?>
      <?php echo ( $logo == '' ) ? $site_name : $site_logo; ?>
      <?php }?>
    </a>

    Then from the code above, check this line: <?php if( is_category(8)){ ?>. Replace 8 to your own category ID where you want this specific logo to appear. Then change this http://virtualhost.dev/latestwp/wp-content/uploads/2016/05/different-logo.jpg to your own logo URL.

    Hope this helps.

    #912744
    chagemeier
    Participant

    THANKS! I will give it a try.

    Curt

    #913116
    Darshana
    Moderator

    Let us know how it goes 🙂

  • <script> jQuery(function($){ $("#no-reply-905058 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>