WordPress.org

Ready to get started?Download WordPress

Forums

Help Explain is_single() Condition (4 posts)

  1. wordpressfan
    Member
    Posted 7 years ago #

    I'm trying to echo some text in a sidebar if we are displaying a single post. I'm having trouble understandin the is_single() conditional statement.

    This is the line that doesn't seem to work:

    if (is_single())
    {
    echo 'this is a single post'
    }

    The statement is in sidebar.php. What am I doing wrong? Thanks,

    Ed

  2. lexhair
    Member
    Posted 7 years ago #

    replace 'this is a single post' with
    'this is a single post';

  3. wordpressfan
    Member
    Posted 7 years ago #

    I added the ';' and it still doesn't print.

    I've also tried the following, without any luck:

    Removed the conditional statement
    Removed the echo statement, leaving just plain text.

    The theme -- Cory Miller's RockinPaper -- prints an 'About' statement in the sidebar, using simple text. I've seen other themes use is_single effectively.

    My goal is to print a sidebar block, listing print, subscribe, and share options for posts.

  4. lexhair
    Member
    Posted 7 years ago #

    My theme has an "about" statment using a condition but it's called by sidebar.php after it checks to see if a dynamic sidebar (widgets) is used. Consequently, the 'about' statement doesn't appear because I use a dynamic sidebar.

    So if you're using widgets, move the 'about' code text in your theme before the call to the dynamic sidebar check.

Topic Closed

This topic has been closed to new replies.

About this Topic