- This topic has 28 replies, 2 voices, and was last updated 2 years, 7 months ago by Andrew Misplon.
- AuthorPosts
- January 31, 2022 at 12:41 pm #16523
KarenParticipantHi 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
January 31, 2022 at 8:08 pm #16524
Andrew MisplonKeymasterHi 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.
February 1, 2022 at 6:19 pm #16527
KarenParticipantThanks 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 ) )
February 1, 2022 at 6:24 pm #16528
Andrew MisplonKeymasterSounds like a plan.
Please, replace
24420
with your page ID.https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
Thanks
February 11, 2022 at 7:21 pm #16548
KarenParticipantThis reply has been marked as private.February 12, 2022 at 6:58 am #16549
Andrew MisplonKeymasterIf you need a hand, let me know 🙂
February 14, 2022 at 6:02 pm #16556
KarenParticipantHi — I keep trying to send a reply but not working. ?
I inserted the php but the site crashed.
February 14, 2022 at 6:02 pm #16557
KarenParticipantI 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
February 14, 2022 at 6:15 pm #16555
KarenParticipantHi 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="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"> <img src="https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg" /> </a> <?php } }
I’m clearly doing something wrong.
February 14, 2022 at 6:15 pm #16554
KarenParticipantHi 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="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"> <img src="https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg" /> </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. 🙂
February 14, 2022 at 6:22 pm #16561
Andrew MisplonKeymasterApologies, 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.
February 14, 2022 at 7:20 pm #16562
KarenParticipantHi 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
February 14, 2022 at 7:42 pm #16567
KarenParticipantHi Andy — Let me know if you got my last reply about pages vs. posts as I don’t see it.
Karen
February 15, 2022 at 10:52 am #16569
Andrew MisplonKeymasterHi Karen
Unfortunately, I don’t see it.
You can target posts using
is_single
.February 15, 2022 at 1:55 pm #16570
KarenParticipantHi 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
- AuthorPosts
The topic ‘Different Logo On Different Pages’ is closed to new replies.