Support » Developing with WordPress » Placing different logos on different pages

  • Resolved muhammadibtehaj

    (@muhammadibtehaj)


    Greetings

    I would like to use different logos on different pages, about 5 logos on 5 different pages. I am not sure how to do it, I searched online but didn’t quite understand the code. I’d be very much pleased if someone help me on this.

    Waiting for the responses
    Regards

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • TOSTAD

    (@tostad)

    Hi,
    you could edit part of header.php that prints your logo in your child theme by using something like this:

    if (is_page( ID_of_page ))
    { print first logo}
    else if (is_page (ID_of_page))
    { print second logo}

    etc…

    Hey @muhammadibtehaj are you referring to having different site logos on each page? I don’t think that is possible without some code updates to your themes.

    Thread Starter muhammadibtehaj

    (@muhammadibtehaj)

    No Andre, I want to print different logos on different pages in one website.
    Like on page 1 – logo 1
    Page 2 – logo 2

    Thread Starter muhammadibtehaj

    (@muhammadibtehaj)

    @tostad What should I write in “{ print first logo }”?
    Should I write the link of image?

    TOSTAD

    (@tostad)

    @muhammadibtehaj Depends on your theme and structure of header.php. You can print your logo in multiple ways, for example
    {echo '<img src="link_to_the_image">';}

    Thread Starter muhammadibtehaj

    (@muhammadibtehaj)

    Hello @tostad, I used your code and wrote this:

    if (is_page( jumbo-collection ))
    {echo ‘‘;}
    else
    {echo ‘‘;}

    but it is not displaying the logo in header instead it is displaying logo in the content space. Also the if function is not working too.

    Please see the link: https://carattere.org/jumbo-collection/

    Thanks

    @muhammadibtehaj if you are using page slug, you have to add parentheses, so the code will look like this:
    if (is_page( 'jumbo-collection' ))
    Now the if statement should work and you just have to find the right place for the code in header.php. Try placing the code higher this time. If that won’t work, could you make a screenshot of header.php file?

    Thread Starter muhammadibtehaj

    (@muhammadibtehaj)

    @tostad I couldn’t find the right place to put code in. This is the code that I am using atm:

    if (is_page (‘jumbo-collection’ ))
        {echo '<img src="Image_link">';}
     else
        {echo '<img src="Image_link">';}

    I am using Neve theme and following is the header.php file code.

    <?php
    /**
     * The template for displaying the header
     *
     * Displays all of the head element and everything up until the page header div.
     *
     * @package Neve
     * @since   1.0.0
     */
    
    $header_classes = apply_filters( 'nv_header_classes', 'header' );
    ?><!DOCTYPE html>
    <html <?php language_attributes(); ?>>
    <head>
    
    	<meta charset="<?php bloginfo( 'charset' ); ?>">
    	<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
    	<link rel="profile" href="http://gmpg.org/xfn/11">
    	<?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?>
    		<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    	<?php endif; ?>
    	<?php wp_head(); ?>
    
    </head>
    
    <body  <?php body_class(); ?> <?php neve_body_attrs(); ?> >
    <?php wp_body_open(); ?>
    <div class="wrapper">
    	<?php neve_before_header_wrapper_trigger(); ?>
    		<header class="<?php echo esc_attr( $header_classes ); ?>" role="banner">
    <a class="neve-skip-link show-on-focus" href="#content" tabindex="0">
    			<?php echo __( 'Skip to content', 'neve' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
    		</a>
    
    	<?php
    		neve_before_header_trigger();
    		if ( apply_filters( 'neve_filter_toggle_content_parts', true, 'header' ) === true ) {
    			do_action( 'neve_do_header' );
    		}
    		neve_after_header_trigger();
    		?>
    	</header>
    	<?php neve_after_header_wrapper_trigger(); ?>
    	<?php do_action( 'neve_before_primary' ); ?>
    
    	<main id="content" class="neve-main" role="main">
    
    <?php
    do_action( 'neve_after_primary_start' );

    See if you can find the right place to put the code.
    Thanks

    @muhammadibtehaj Unfortunately, in your theme, this can’t be easily done in header.php. You will have to look further, to the particular functions. Either neve_before_header_trigger, action neve_do_header or neve_after_header_trigger. But that could be a little more complicated.

    Easy solution that comes to mind, although a dirty one, could be placing the logo somewhere between these functions so it shows up in header, style it with CSS if needed, and then hide the original logo with page specific CSS.

    • This reply was modified 9 months, 4 weeks ago by TOSTAD.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Placing different logos on different pages’ is closed to new replies.