Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted

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. :)

share|improve this answer
add comment

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 the

define('WP_DEBUG', false);

change to true, like this:

define('WP_DEBUG', true);

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.