Tagged: x
-
AuthorPosts
-
April 28, 2016 at 9:18 pm #905058
chagemeierParticipantI 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,
CurtApril 29, 2016 at 11:13 am #905848
ThaiModeratorHi 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.
May 3, 2016 at 9:30 pm #911764
chagemeierParticipantI’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,
CurtMay 4, 2016 at 4:19 am #912128
LelyModeratorHello 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 thishttp://virtualhost.dev/latestwp/wp-content/uploads/2016/05/different-logo.jpgto your own logo URL.Hope this helps.
May 4, 2016 at 11:16 am #912744
chagemeierParticipantTHANKS! I will give it a try.
Curt
May 4, 2016 at 3:06 pm #913116
DarshanaModeratorLet us know how it goes 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-905058 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
