Resolved

Different Logo On Different Pages

Ultra Theme started by Karen Jan 31, 2022 28 replies
Karen Jan 31, 2022 · 12:41 pm #16523

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

Andrew Misplon Puro Jan 31, 2022 · 8:08 pm #16524

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.

Karen Feb 1, 2022 · 6:19 pm #16527

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 ) )

Karen Feb 11, 2022 · 7:21 pm #16548

This reply has been marked as private.

Andrew Misplon Puro Feb 12, 2022 · 6:58 am #16549

If you need a hand, let me know 🙂

Karen Feb 14, 2022 · 6:02 pm #16556

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

I inserted the php but the site crashed.

Karen Feb 14, 2022 · 6:02 pm #16557

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

Karen Feb 14, 2022 · 6:15 pm #16555

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.

Karen Feb 14, 2022 · 6:15 pm #16554

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. 🙂

Andrew Misplon Puro Feb 14, 2022 · 6:22 pm #16561

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

Karen Feb 14, 2022 · 7:20 pm #16562

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

Karen Feb 14, 2022 · 7:42 pm #16567

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

Karen

Karen Feb 15, 2022 · 1:55 pm #16570

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() . '/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

29 posts
Closed This topic is closed to new replies. Still stuck? Start a new topic in Ultra Theme.