• Resolved tjobbe

    (@tjobbe)


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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter tjobbe

    (@tjobbe)

    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.

    Thread Starter tjobbe

    (@tjobbe)

    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 ‘Only show sidebar on home page?’ is closed to new replies.