Jump to content

Conditional, PHP statement in Wordpress


preeminent

Recommended Posts

Hey all!

  I have a question and I'm thinking it's probably an easy fix. I have messed around with conditional and else/if statements for this, but cannot wrap my head around how to fix this problem.

I have a wordpress theme I'm working on, and on ONE page of it, I need a different logo in the header than the rest of the site. I have it setup so that, that logo appears on the "STORE" template page. That part is working fine. But my problem is that the default "Bloglogo" logo is also showing on this page along side of the "preemplateslogo" store logo. I only want the "preemplateslogo.png" to show on this store page, not the "bloglogo.png" which is displayed on every other page of the site. Here is what I'm working with:

<?php if (is_page_template('store.php')) { ?>
        <a href="<?php bloginfo('url') ?>"><img src="<?php bloginfo('template_url'); ?>/assets/img/preemplateslogo.png" alt="Preemplates" /></a> 
        <?php } ?>
        
        		
	<?php $customField1 = get_option("theme_logo");
	        if (isset($customField1[0])) { ?>	
	        	
			<a href="<?php bloginfo('url') ?>"><img src="<?php echo get_option('theme_logo',true); ?>" alt="Logo" /></a>

	<?php } else { ?> <a href="<?php bloginfo('url') ?>"><img src="<?php bloginfo('template_url'); ?>/assets/img/bloglogo.png" alt="Preeminent Productions Blog" /></a> <?php } ?>
	</div>

 

 

The first statement is pulling in that store logo just fine. I just need to edit the second part to NOT SHOW the "bloglogo.png" on this particular page. I hope this makes sense and thank you!

Link to comment
Share on other sites

  • 4 weeks later...

use the if else statement to match to the page id, not the url.

 

<?php if ( $page_id ) {?><img src="logo.png" title="Logo"> <? } else {} ?>[/php

or if it is the homepage, try this:

[code=php:0]<?php if ( is_front_page() ) {?><img src="logo.png" title="Logo"> <? } else {} ?>

 

then use else to display the image for every other page...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.