Support » Developing with WordPress » Sidebar on homepage only

  • Fiona


    How can I make it so my sidebar is only on the homepage and not on every page?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Fiona

    I do not know your theme, but you can make a child-theme, and delete the sidebar section from all files, except for front-page.php.

    You are using the Avant theme that has a sidebar.php file. Make the contents of that file:

     * The sidebar containing the main widget area.
     * @package Avant
    if ( ! is_active_sidebar( 'sidebar-1' ) ) {
    } ?>
    <div id="secondary" class="widget-area <?php echo ( get_theme_mod( 'avant-page-sidebar-blocks' ) ) ? sanitize_html_class( 'sidebar-break-blocks' ) : ''; ?>" role="complementary">
    	<?php dynamic_sidebar( 'sidebar-1' ); ?>
    </div><!-- #secondary -->
    <?php } ?>

    That will show the sidebar only on the home page.

    Now keeping mind this is just not showing the sidebar on other pages not changing the CSS in any way so your content area will not span the entire screen. If you want it to, you can try:

    .woocommerce #container, .woocommerce-page #container, .content-area {
        width: 100%;
        margin: 0;
    .home .woocommerce #container, .home .woocommerce-page #container, .home .content-area {
        width: 70%;
        margin: 0 5% 0 0;
    Thread Starter Fiona


    Thanks both.
    Is there a way to display tweets in the footer rather than in the sidebar and if so how?

    Moderator bcworkz


    It depends on what plugin you use to get tweets. If it offers a shortcode, you could add something like <?php echo do_shortcode('[plugins-shortcode-here]'); ?> to the theme footer template. If only widgets are available, they can only be added to widget areas designated by your theme. If your theme does not offer a widget area in the footer, you could make a child theme and have it create a footer widget area. If you’re altering the footer template in any way you should create a child theme anyway.

    N.B. – Even if the widget area is in the header or footer, in code it’s still called a “sidebar”, e.g. dynamic_sidebar('widget-area-name');

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Sidebar on homepage only’ is closed to new replies.