WordPress.org

Support

Support » How-To and Troubleshooting » Custom Sidebar Content for “Single” Page

Custom Sidebar Content for “Single” Page

  • Ultimately, I’d like to move the “This entry was posted on… You can skip…” blurb to the sidebar. I checked the codex and found this page, which describes how to do custom sidebar content, but it didn’t say much of anything about which WP functions work.

    Here’s the code I want to use:
    <?php
    if (is_single())
    {
    ?>
    Archived Entry
    <div class="nentry">
    <strong>Posted On:</strong> <?php echo the_time('l, F jS, Y') ?>
    </div>

    <?php
    }
    ?>

    While the section does show up (the conditional statement is working), the time doesn’t show up. I assume it’s because the_time() inside the “loop.” What would I have to do to make the time show up for that post in this spot?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The Codex says about all the time/date related template tags that they work only inside The Loop… 🙁

    Theoretically, you could move the whole sidebar into The Loop (since it’s the single-post template you should only get one sidebar…;-)). You’d need a separate sidebar for single.php than you’re using for the index/archives, of course.

    There might be other complications that arise when you do that, but it wouldn’t break your computer to try it.

    …Or could you create a second Loop for the sidebar?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Sidebar Content for “Single” Page’ is closed to new replies.