sidebar isn’t showing, what’s wrong w/ this code?

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?

Read More

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>

Related posts

Leave a Reply

2 comments

  1. 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. 🙂

  2. 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.