I want to use different logo for my home page and another logo for others page in wordpress.what will be the changes in header file and css.Currently i am using terminus theme.
3 Answers
You can do that using condition in your header file like
if(is_front_page() || is_home())
{
// PUT YOUR HOME PAGE LOGO HERE
}else{
// PUT LOGO FOR INNER PAGES
}
Hope it will help you!
This CSS only example works on the Terminus demo site on Themeforest. The only difference is that demo site didn't have a page ID.
You'll need to look up the page/post IDs for the pages/posts you want to have different logos anyway. Then replace the example ID class I have below with your ID class.
Here's how to get the page/post ID.
/**
* Hide the default logo.
*
* For posts use .postid-1 format.
*/
.page-id-1 .logo img {
display: none;
}
/**
* Drop in a different logo.
*
* The site link is respected.
*/
.page-id-1 .logo {
background-image: url(https://balistreetphotographer.files.wordpress.com/2019/02/balistreetphotographer-logo-2-slashes-65.png);
background-repeat: no-repeat;
background-size: 100%;
display: block;
position: relative;
height: 65px;
width: 65px;
}
Obviously change the logo URL and logo dimensions to yours.
Good luck!
<?php if(is_front_page() || is_home()) : ?>
<a href="<?php echo esc_url( home_url( '/' )); ?>">
<img src="<?php bloginfo('template_url')?>/images/logo.png" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="logo-width" alt="logo">
<?php else : ?>
<img src="<?php bloginfo('template_url')?>/images/white_logo.png" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="logo-width" alt="white-logo">
<?php endif; ?>
</a>
-
Use the above condition in header.php file. hope it will helps Commented Jan 21, 2023 at 13:11