Solved

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

Posted on 2013-06-12
8
253 Views
Last Modified: 2013-09-18
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
Comment
Question by:angelic_webmaster
  • 3
  • 2
8 Comments
 
LVL 25

Assisted Solution

by:James Rodgers
James Rodgers earned 100 total points
ID: 39244305
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
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 400 total points
ID: 39253331
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
 

Author Comment

by:angelic_webmaster
ID: 39264145
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:angelic_webmaster
ID: 39299292
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
 
LVL 17

Expert Comment

by:jrm213jrm213
ID: 39304603
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
 

Author Closing Comment

by:angelic_webmaster
ID: 39504168
Thank you all for helping me. The code was great - although I went a different route :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now