[Resolved] Different Logo On Different Pages

  • Author
    Posts
  • #16523

    Karen
    Participant

    Hi there,

    My client wants some of the interior pages to have a different logo from the homepage. I’ve been doing a bit of research (aka Googling) and think I need to build a custom template. Or can I use CSS and the page ID?

    I have Ultra Premium for this website, and wondering if there is a quick way to do this? I’ve not created a custom template before, so checking here first.

    Thanks, Karen

    #16524

    Andrew Misplon
    Keymaster

    Hi Karen

    Thanks for your support and for reaching out.

    Unfortunately, it doesn’t seem like we can do this with the Code Snippets plugin. If possible, please, install a child theme if you aren’t already using one and add the functions.php file:

    if ( is_page( 24420 ) ) {
    	function ultra_display_logo() { ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    			<img src="http://localhost/puro/wp-content/uploads/2021/05/ruud-luijten-4MHr9v1jVEA-unsplash-scaled-1.jpg" />
    		</a>
    	<?php }
    }

    Replace the image URL with yours.

    A starter child theme for Ultra can be found here https://purothemes.com/documentation/ultra-theme/child-theme-library/.

    A guide on how to migrate theme settings from the parent to the child theme can be found here https://purothemes.com/customizer-settings-export-import/.

    We might need to make a few adjustments. Let me know how you get on.

    #16527

    Karen
    Participant

    Thanks Andrew — I’ll give this a try and report back.

    I already have a child theme and I assume I also need to insert my own page id in these brackets?

    if ( is_page( 24420 ) )

    #16528

    Andrew Misplon
    Keymaster

    Sounds like a plan.

    Please, replace 24420 with your page ID.

    https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page

    Thanks

    #16548

    Karen
    Participant
    This reply has been marked as private.
    #16549

    Andrew Misplon
    Keymaster

    If you need a hand, let me know 🙂

    #16556

    Karen
    Participant

    Hi — I keep trying to send a reply but not working. ?

    I inserted the php but the site crashed.

    #16557

    Karen
    Participant

    I think my reply is being rejected as I’m putting in php code but I am using the open and close code tags in the text box.

    Let me try one other thing first. I’ve just downloaded your child theme starter pack hoping it might have a functions.php file in it …. which it does. So I’m using that and will give it another go.

    Karen

    • This reply was modified 4 months, 1 week ago by Karen. Reason: update
    #16555

    Karen
    Participant

    Hi Andy

    I tried inserting the functions.php into my child theme but it crashed the site. At first, I copied over the entire functions.php and added your code snippet right at the top, and then tried just the code snippet by itself (below). Both crash the site.

    <?php
    /**
     * Ultra functions and definitions.
     *
     * @link https://developer.wordpress.org/themes/basics/theme-functions/
     *
     * @package ultra
     * @since ultra 0.9
     * @license GPL 2.0
     */
    
    if ( is_page( 2479 ) ) {
            function ultra_display_logo() { ?>
                    <a href=&quot;<?php echo esc_url( home_url( '/' ) ); ?>&quot; rel=&quot;home&quot;>
                            <img src=&quot;https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg&quot; />
                    </a>
            <?php }
    }
    
    

    I’m clearly doing something wrong.

    #16554

    Karen
    Participant

    Hi Andy

    When I add the functions.php to my child theme the site crashes. I’ve created a php file with the following code inserted (and nothing else).

    <?php
    /**
     * Ultra functions and definitions.
     *
     * @link https://developer.wordpress.org/themes/basics/theme-functions/
     *
     * @package ultra
     * @since ultra 0.9
     * @license GPL 2.0
     */
    
    if ( is_page( 2479 ) ) {
            function ultra_display_logo() { ?>
                    <a href=&quot;<?php echo esc_url( home_url( '/' ) ); ?>&quot; rel=&quot;home&quot;>
                            <img src=&quot;https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg&quot; />
                    </a>
            <?php }
    }
    
    

    I also copied the entire functions.php file from the main theme and added this code at the top, but it still crashed.

    Need some direction please. 🙂

    #16561

    Andrew Misplon
    Keymaster

    Apologies, please, try:

    if ( ! function_exists( 'ultra_display_logo' ) ) :
    if ( is_page( 24420 ) ) {
    	function ultra_display_logo() { ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    			<img src="http://localhost/puro/wp-content/uploads/2021/05/ruud-luijten-4MHr9v1jVEA-unsplash-scaled-1.jpg" />
    		</a>
    	<?php }
    }
    endif;

    Here is how the function.php file should look in your child theme. Please, reverse any changes made to the code in your parent theme.

    View post on imgur.com

    #16562

    Karen
    Participant

    Hi Andy,

    Thanks for that. I’ve uploaded the correct functions.php file but the logo hasn’t changed.

    When I edit the page, the URL is post=2479 .. so, should is_page be changed to is_post?

    Here’s my code below:

    <?php
    
    /**
     * Enqueue the parent theme stylesheet.
     */
    function ultra_child_enqueue_parent_style() {
    	wp_enqueue_style( 'ultra-parent-style', get_template_directory_uri() . '//puro-4401.kxcdn.com/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'ultra_child_enqueue_parent_style' );
    
    if ( ! function_exists( 'ultra_display_logo' ) ) :
    if ( is_page( 2479 ) ) {
    	function ultra_display_logo() { ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    			<img src="https://www.eqpartnering.co.uk/wp-content/uploads/2018/11/gallifordTry.jpg" />
    		</a>
    	<?php }
    }
    endif;

    Karen

    • This reply was modified 4 months, 1 week ago by Karen.
    • This reply was modified 4 months, 1 week ago by Karen.
    • This reply was modified 4 months, 1 week ago by Karen.
    • This reply was modified 4 months, 1 week ago by Karen.
    #16567

    Karen
    Participant

    Hi Andy — Let me know if you got my last reply about pages vs. posts as I don’t see it.

    Karen

    #16569

    Andrew Misplon
    Keymaster

    Hi Karen

    Unfortunately, I don’t see it.

    You can target posts using is_single.

    https://codex.wordpress.org/Conditional_Tags#Single_Post

    #16570

    Karen
    Participant

    Hi Andy

    OK, will try again.

    I inserted the functions.php file into my child theme, identified the page and changed the image URL but it hasn’t worked. (Code below).

    <?php
    
    /**
     * Enqueue the parent theme stylesheet.
     */
    function ultra_child_enqueue_parent_style() {
    	wp_enqueue_style( 'ultra-parent-style', get_template_directory_uri() . '//puro-4401.kxcdn.com/style.css' );
    }
    add_action( 'wp_enqueue_scripts', 'ultra_child_enqueue_parent_style' );
    
    if ( ! function_exists( 'ultra_display_logo' ) ) :
    if ( is_page( 2479 ) ) {
    	function ultra_display_logo() { ?>
    		<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
    			<img src="https://www.eqpartnering.co.uk/wp-content/uploads/2018/11/gallifordTry.jpg" />
    		</a>
    	<?php }
    }
    endif;

    My question was that when I edit the page, it’s a post not a page (post=2479). So, has it not worked because the code specifies a ‘page’ rather than a ‘post’? Or is there another problem?

    Karen

Viewing 15 posts - 1 through 15 (of 29 total)

The topic ‘Different Logo On Different Pages’ is closed to new replies.

Scroll to top