views:

28

answers:

2

Hey all,

Quick question about Wordpress PHP: I am writing a theme and I want to display (on the main index page) one icon if my post has one tag, and another if it has the other.

I wrote something like

<?php has_tag('pc') { ?><img src="<?php bloginfo('template_directory'); ?>/images/pc-icon.gif"><?php }; ?>
<?php has_tag('mb') { ?><img src="<?php bloginfo('template_directory'); ?>/images/mb-icon.gif"><?php }; ?>

But it gives me an error. Can anybody help?

Thanks

+1  A: 
<?php if(has_tag('pc')) { ?><img src="<?php bloginfo('template_directory'); ?>/images/pc-icon.gif"><?php }; ?>
<?php if(has_tag('mb')) { ?><img src="<?php bloginfo('template_directory'); ?>/images/mb-icon.gif"><?php }; ?>

You're missing the if.

Tatu Ulmanen
Awesome. THANK YOU!
StormShadow
Answer accepted.
StormShadow
+1  A: 

try this:

<?php if(has_tag('pc')) { ?><img src="<?php bloginfo('template_directory'); ?>/images/pc-icon.gif"><?php }; ?>
<?php if(has_tag('mb')) { ?><img src="<?php bloginfo('template_directory'); ?>/images/mb-icon.gif"><?php }; ?>
silent
You guys are AWESOME! Thanks for getting back to me so quick. It works perfectly.
StormShadow
Answer accepted.
StormShadow