The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] Diffirent sidebar for single posts (2 posts)

  1. fakelvis
    Posted 10 years ago #


    I would like to display a different sidebar when a user is viewing a single post.

    I could do this by creating single.php, then copying everything and calling a new file, say, singlefooter.php which in turn calls my new sidebar.

    This is so long-winded though and I was wondering if there's an easier way.

    On my sidebar.php file I was hoping to run an if statement to see if it was displaying a single post. If so display one thing, if not the other.

    It's only a small difference (displaying a 1-picture flickr badge rather than a 5-picture badge) so don't fancy creating all the new files for one small change.

    Basically what do I need to call in my if statement to see if it is a single post?


  2. fakelvis
    Posted 10 years ago #

    After a few extra hours of searching I came across the conditional tags. Bingo.

    Just so others know, I've done the following:

    <?php if (is_single())

    Substituting 1 for the html code when it is a single post and substituting 2 for the html code for other times.

    Hope this helps someone else too.

Topic Closed

This topic has been closed to new replies.

About this Topic