WordPress.org

Ready to get started?Download WordPress

Forums

Custom Sidebar Content for "Single" Page (3 posts)

  1. alienvenom
    Member
    Posted 9 years ago #

    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?

  2. moshu
    Member
    Posted 9 years ago #

    The Codex says about all the time/date related template tags that they work only inside The Loop... :(

  3. michaelc
    Member
    Posted 9 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.