WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Only show sidebar on home page?

[Resolved] Only show sidebar on home page?

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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.

    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.

    Thanks!

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

    @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 }?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Only show sidebar on home page?’ is closed to new replies.