Hey all, I have a problem and I'm sure it's a very simple fix. I have one page of my wordpress site that needs to have a different logo image than the rest of the site. It's working fine, except it's also bringing in the default logo as well. I've been playing around with if/else statements and conditional tags, but cannot wrap my head around how to get this to work. I really don't know any php, I've used just what I've seen from tutorials. Here is what I currently have: <!-- BEGIN LOGO --> <div class="logo">
As you can see, when you are on the "STORE" template page, I need that "preemplateslogo.png" logo to display, which it is doing perfectly, but I now need to customize the rest of this code (that came with the theme I'm using). What's happening though, is the default, regular "bloglogo.png" logo is also showing up right next to the "preemplateslogo.png" logo. How do I edit this, so that only the top statement is utilized on the "STORE" template page. I hope this makes sense to you all! Thanks!
Thank you very much for your reply. I tried it and it now throws a "Parse error: syntax error, unexpected" in the "<?php } else { ?><!-- I have added an else here... --> line.
The above code worked for me, although I simplified it a bit using my own images and removing the bloginfo('url') and such so you should put that back. It should still work then however.
Bob! Thank you so much for your reply. Well your method kind of works, but it makes the secondary "preemplates" store logo appear on all pages of my blog. I need it to appear only on the store page. My question is this: With the $var==1 and $var==2 parts of the code. How do I assign the different logos to each of those $var's? If I can somehow assign the logo to $var==2 for example then it will work great.
The $var==1 and $var==2 was just an example for me to be able to test it locally, 'cause if I used is_page_template('store.php'), it wouldn't work for me since I obviously don't have that page template here on my computer.
Can you post your code like you have it now? Or did you not modify it at all? The code I posted above worked fine for me like I said, but you have to adapt it to fit your needs like I said. Thus, replace if ( $var==1 ) with if (is_page_template('store.php')) and so on. Basically, from what I see, the if..elseif..else statements I created should work; you just have to adapt it to your own code, so please post back what you have now.
I started to adapt the code for my use, but now I don't know what I replace $var =1; and elseif ( $var==2) with? In other words, with my original code(up at the top of this thread) I don't have the elseif ( $var==2 ) anywhere in use. So how should I edit that?
I've adapted it so it should fit your needs exactly. I put back in your links to your images etc. Try this code to see if it works, and if it doesn't, post back why it isn't working.
Ok, I'm back. It looks like you edited the original code by adding elseif instead of just if in the line elseif ( isset($customField1[0]) ) correct? That is throwing a syntax error and the site won't load with it added. This is crazy, haha. I figured it would be something so easy.
Hey bob, Here is the error message: Parse error: syntax error, unexpected T_ELSEIF in /homepages/37/d221555405/htdocs/blog/wp-content/themes/aspire/header.php on line 133" which, of course is elseif ( isset($customField1[0]) )
Replace templatenamehere with another template you have, just make sure its different from store.php 'cause thats already being used in the first if statement so you wouldn't see any difference then. Its just for testing purposes so either create a test template and use that in the above elseif statement or use an other template you have. See if that helps.
BOB! You are awesome, thank you sir! That did the trick! But wait, so I guess I could just leave this elseif ( is_page_template('TESTtemplate.php' ) ) the way it is then? I mean I obviously won't use the "testtemplate.php" on any real page of my blog. So it won't really matter if I leave it in there. I really appreciate your time on this!
But hang on, if you leave it like that, you do realize the <img src="<?php echo get_option('theme_logo',true); ?>" alt="Logo" />, which belongs to the elseif ( is_page_template('TESTtemplate.php' ) ), will never show up right? If you're ok with that, I'm glad because that means its working for you, but if you don't mind it showing up at all, why did you add an if statement for it in the first place (see your first post)? Don't you need the image to show sometime?
AH! ok, I knew I was forgetting something! Well basically that statement is grabbing a logo from the theme's settings area. It's optional. In other words, I could just link to a logo that I want used in my theme, right into my theme's setting area. And I wouldn't need to even worry about hard coding my logo into my pages. Does that make sense? So basically, I'm not using that option, obviously, and I'm hard coding it right in. HAHA, but now I realize I completely made this simple problem even more complicated, right? So taking that <img src="<?php echo get_option('theme_logo',true); ?>" alt="Logo" /> out of the equation, how should I of written this code?
I have a problem and I'm sure it's a very simple fix. I have one page of my wordpress site that needs to have a different logo image than the rest of the site. It's working fine, except it's also bringing in the default logo as well. I've been playing around with if/else statements and conditional tags, but cannot wrap my head around how to get this to work. I really don't know any php, I've used just what I've seen from tutorials. Here is what I currently have:
<!-- BEGIN LOGO -->
<div class="logo">
<?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>
<!-- END LOGO -->
As you can see, when you are on the "STORE" template page, I need that "preemplateslogo.png" logo to display, which it is doing perfectly, but I now need to customize the rest of this code (that came with the theme I'm using). What's happening though, is the default, regular "bloglogo.png" logo is also showing up right next to the "preemplateslogo.png" logo. How do I edit this, so that only the top statement is utilized on the "STORE" template page. I hope this makes sense to you all! Thanks!
<?php } else { ?><!-- I have added an else here... -->line.The above code worked for me, although I simplified it a bit using my own images and removing the bloginfo('url') and such so you should put that back. It should still work then however.
$var==1and$var==2parts of the code. How do I assign the different logos to each of those $var's? If I can somehow assign the logo to $var==2 for example then it will work great.$var==1and$var==2was just an example for me to be able to test it locally, 'cause if I used is_page_template('store.php'), it wouldn't work for me since I obviously don't have that page template here on my computer.Can you post your code like you have it now? Or did you not modify it at all? The code I posted above worked fine for me like I said, but you have to adapt it to fit your needs like I said. Thus, replace
if ( $var==1 )withif (is_page_template('store.php'))and so on.Basically, from what I see, the if..elseif..else statements I created should work; you just have to adapt it to your own code, so please post back what you have now.
Here is where I'm at now,but I'm stuck:
<div class="logo">
<!--Check page type-->
<?php
$var = 1;
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 }
elseif ( $var==2 )
{ ?>
<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>
<!-- END LOGO -->
I started to adapt the code for my use, but now I don't know what I replace
$var =1;andelseif ( $var==2)with? In other words, with my original code(up at the top of this thread) I don't have theelseif ( $var==2 )anywhere in use. So how should I edit that?I've adapted it so it should fit your needs exactly. I put back in your links to your images etc.
Try this code to see if it works, and if it doesn't, post back why it isn't working.
elseifinstead of justifin the lineelseif ( isset($customField1[0]) )correct? That is throwing a syntax error and the site won't load with it added. This is crazy, haha. I figured it would be something so easy.Here is the error message: Parse error: syntax error, unexpected T_ELSEIF in /homepages/37/d221555405/htdocs/blog/wp-content/themes/aspire/header.php on line 133" which, of course is
elseif ( isset($customField1[0]) )Maybe set that before the main 'if'?
And replacing the line:
with the line:
Replace templatenamehere with another template you have, just make sure its different from store.php 'cause thats already being used in the first if statement so you wouldn't see any difference then. Its just for testing purposes so either create a test template and use that in the above elseif statement or use an other template you have.
See if that helps.
elseif ( is_page_template('TESTtemplate.php' ) )the way it is then? I mean I obviously won't use the "testtemplate.php" on any real page of my blog. So it won't really matter if I leave it in there. I really appreciate your time on this!But hang on, if you leave it like that, you do realize the
<img src="<?php echo get_option('theme_logo',true); ?>" alt="Logo" />, which belongs to theelseif ( is_page_template('TESTtemplate.php' ) ), will never show up right? If you're ok with that, I'm glad because that means its working for you, but if you don't mind it showing up at all, why did you add an if statement for it in the first place (see your first post)? Don't you need the image to show sometime?<img src="<?php echo get_option('theme_logo',true); ?>" alt="Logo" />out of the equation, how should I of written this code?