Here’s what I have in my sidebar.php:
<aside id="sidebar">
<?php if ( is_user_logged_in() ) {
echo '<a href="/community"><img id="visit-the-forums" src="'. bloginfo('template_url') . '/images/visit-the-forums.png" alt="Check out the Forums!" /></a>'
} else {
echo '<a href="/community"><img id="join-the-forums" src="'. bloginfo('template_url') . '/images/join-the-forums.png" alt="Join the Forums!" /></a>'
}
?>
<a id="side-ad">
<img src="<?php bloginfo('template_url') ?>/images/ipad-ad.png" alt="iPad 2 Giveaway!" />
</a>
</aside>
For some reason, it doesn’t show (not even in the markup) for any of the pages. I’ve double-checked all of the other templates to make sure <?php get_sidebar(); ?>
is included. Is there something wrong w/ the code above?
Edit: I should note that the below works, that is, without the if/else statement.
<aside id="sidebar">
<a href="/community"><img id="join-the-forums" src="<?php bloginfo('template_url') ?>/images/join-the-forums.png" alt="Join the Forums!" /></a>
<a id="side-ad">
<img src="<?php bloginfo('template_url') ?>/images/ipad-ad.png" alt="iPad 2 Giveaway!" />
</a>
</aside>
Does the markup after
<?php get_sidebar(); ?>
show up?I would guess that this is a silent PHP error, as your lines within the if/else block do not end with semi-colons. 🙂
The semicolons should be present at the end of each echo within if/else.
To help you find some mistakes it is a good practice to activate the WordPress debug variable, so you get some notices about your code.
You can do it replacing false for true in the WP_DEBUG var.
Find in your wordpress root instalation for the file
wp-config.php
, backup it, after open/edit and search for the line containig thechange to true, like this:
Now, when opening you wite to test your code, if there is some error or notice, you will get in the top of the page. Even in Dasbord.