• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

Wordpress - how to make 2 different logos - one on some pages one on others

Here is the website. Trying to make two logos appear. One on a few pages, and another on other pages?

http://www.ronhenrey.com/welcome/
0
angelic_webmaster
Asked:
angelic_webmaster
  • 3
  • 2
2 Solutions
 
James RodgersWeb Applications DeveloperCommented:
take a look here
http://codex.wordpress.org/Function_Reference/is_page
this will let you set up an if to determine which page you are on and show the logo accordingly
0
 
jrm213jrm213Commented:
I would recommend doing this all through the wordpress functionality and then just making one change to the header.php page so that you can specify what logo to display when creating/editing a wordpress page.

In your header.php replace your img tag for the logo with the following.
<?php
$logoImg = get_post_meta(get_the_ID(),'logo-image');
try
{
	$logoImg = $logoImg[0];
}
catch (Exception $e)
{
	$logoImg = "/wp-content/images/uploads/default-logo.png"; //place a default image here for pages that don't have it set
}
?>
	<img src="<?php	echo $logoImg;?>" alt="Logo"/>

Open in new window


then in your pages add a "Custom Field" named "logo-image" and add the path and image name for the value.


this way you don't have to edit an "if is_page()" block or case statement every time you add a page, and you could display any image you wanted there.
0
 
angelic_webmasterAuthor Commented:
Ok I will try these both and let you know.
My father passed away this last week so I have not been able to respond.
0
Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

 
angelic_webmasterAuthor Commented:
Would this still work on my new template I am using.
<?php
$logoImg = get_post_meta(get_the_ID(),'logo-image');
try
{
	$logoImg = $logoImg[0];
}
catch (Exception $e)
{
	$logoImg = "/wp-content/images/uploads/default-logo.png"; //place a default image here for pages that don't have it set
}
?>
	<img src="<?php	echo $logoImg;?>" alt="Logo"/>

Open in new window


www.ronhenrey.com
0
 
jrm213jrm213Commented:
re: post 39299292

Yes that should still work.
If you have a custom field  named "logo-image" on a page it should display that image. If you don't have that custom field on a page, it will display the default image.
0
 
angelic_webmasterAuthor Commented:
Thank you all for helping me. The code was great - although I went a different route :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now