WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Only show sidebar on home page? (6 posts)

  1. tjobbe
    Member
    Posted 5 years ago #

    Is it possible to only show the sidebar on the home page, and if so, how would I do this?

  2. tjobbe
    Member
    Posted 5 years ago #

    I have searched for this believe it or not, maybe I'm using the wrong search terms but I can't seem to find a way round this.

  3. stvwlf
    Member
    Posted 5 years ago #

    edit your sidebar.php file, found in the theme files in the /wp-content/themes/{theme-name} folder

    put this as the first line:
    <?php if ( is_front_page() ) { ?>

    and this as the last line:
    <?php } ?>

    That will cause the sidebar contents to only display on your home page.

  4. tjobbe
    Member
    Posted 5 years ago #

    Thanks!

  5. lovablechelsey
    Member
    Posted 5 years ago #

    Is there a way to achieve the opposite? I.e. the sidebar showing up on every page EXCEPT the home page?

  6. jack.x.johnson
    Member
    Posted 5 years ago #

    @lovablechelsey

    Just add an " ! "(it means not) in front of is_front_page() function like this :
    <?php if ( !is_front_page() ) { ?>
    your code here ....
    <?php } ?>

    or just use else like this :
    <?php if ( is_front_page() ) { ?>
    stuff that is displayed only on front page

    <?php }
    else {
     ?>

    other stuff that is displayed on other pages
    <?php }?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.