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

Karen Feb 15, 2022 · 5:55 pm #16572

Not sure why they are posts when I’ve created them as pages, but will give that a try.

Andrew Misplon Puro Feb 15, 2022 · 5:57 pm #16573

Please, send a link to the page concerned and I’ll take a look. Thanks.

Karen Feb 15, 2022 · 6:05 pm #16574

Page Link

I’ve got a few pages within this site that will need different logos. If I can get it working for one, pretty sure I can roll it out to the others.

I’m not sure how to use the is_single code, sorry.

Andrew Misplon Puro Feb 15, 2022 · 7:26 pm #16575

Super, thanks for the link. Apologies for the hassle; I see where the issue is. I’ll get back to you ASAP tomorrow with a complete solution.

Karen Feb 15, 2022 · 7:30 pm #16576

OK, sounds good. Thanks Andy.

Andrew Misplon Puro Feb 16, 2022 · 8:10 pm #16580
if ( ! function_exists( 'ultra_child_alt_logo' ) ) :
function ultra_child_alt_logo( $logo_html ) {
	if ( is_page( 24420 ) ) {
		$logo_html = preg_replace('/<img(.*?)\/>/', '<img src="https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg" itemprop="logo" />', $logo_html );
	}

	if ( is_page( 24421 ) ) {
		$logo_html = preg_replace('/<img(.*?)\/>/', '<img src="https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg" itemprop="logo" />', $logo_html );
	}

	return $logo_html;
}
endif;
add_filter( 'ultra_logo_image', 'ultra_child_alt_logo' );
Andrew Misplon Puro Feb 16, 2022 · 8:13 pm #16581

Hi Karen

Please, try the above. Please, copy the function directly from the forum and not from email. You can replace the IDs with your IDs and the image URLs with the required URL per page. The if conditional can be duplicated for new pages:

if ( is_page( 24421 ) ) {
	$logo_html = preg_replace('/<img(.*?)\/>/', '<img src="https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg" itemprop="logo" />', $logo_html );
}
Karen Feb 21, 2022 · 3:46 pm #16594

Hi Andy,

That worked perfectly! I can easily swop out the page IDs and image URLs and now have different logos on 3 different pages.

Brilliant support as always. Thanks Andy 🙂

Karen

P.S. (Hope you don’t get this reply 3 times. Every time I click Submit, the message disappears?)

Andrew Misplon Puro Feb 22, 2022 · 8:29 am #16607

Hi Karen

Super, I’m glad to hear you’re making progress. Thanks for the update 🙂

(bbPress put your first two replies into a pending mode for manual review. If that happens, no worries, I’ll manually approve the replies when I’m next online. I’ll delete the additional replies shortly.)

Karen Feb 23, 2022 · 5:36 pm #16610

Hi Andy

Ah ok. thanks for explaining the bbPress bit.

Follow up question. If I have 3 pages that need one logo and 2 that need another, do I have to duplicate the conditional for each page, or can I add the other page IDs using a comma?

Example:

if ( is_page( 24421, 346, 123 ) ) {
	$logo_html = preg_replace('/<img(.*?)\/>/', '<img src="https://www.eqpartnering.co.uk/wp-content/uploads/2022/01/woodmeadow-trust.jpeg" itemprop="logo" />', $logo_html );
}
Andrew Misplon Puro Feb 24, 2022 · 11:27 am #16611

“3 pages that need one logo” would go in one conditional.

“2 that need another” would go in another conditional.

You can use commas for multiple IDs in an array as follows:

is_page( array( 42, 54, 6 ) )

Examples using the is_page conditional can be found at https://developer.wordpress.org/reference/functions/is_page/. Scroll down to the bottom.

Thanks 🙂

Karen Feb 25, 2022 · 3:18 pm #16616

Brilliant. Thanks Andrew.

Andrew Misplon Puro Feb 25, 2022 · 6:41 pm #16619

Glad to hear you’re making progress 🙂

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