Underscores Wordpress Theme - Adding second sidebar

三世轮回 提交于 2019-12-11 03:55:38

问题


Stared a Wordpress site using Underscores theme (_s)

I have got one sidebar working but want to make a second one to be on the same page. (containing different widgets)

I have added the new sidebar to the functions.php and it appears in the Wordpress login screen and i can drop widgets into it. However, I can't get it to show on the actual webpage. (the first sidebar is working fine)

Anyone know how to do this or know a tutorial...

Thanks


回答1:


You'll need to edit the "sidebar.php" file in your theme folder. It should normally be:

<div id="secondary" class="widget-area" role="complementary">
    <?php do_action( 'before_sidebar' ); ?>

    <?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
    <?php endif; // end sidebar-1 widget area ?>

</div><!-- #secondary -->

You will need to add another if statement that looks out for the other sidebar. Be sure to reference it by whatever you used in the functions.php file.

If you want it to appear below the current sidebar, just be sure to add it before closing the 'div' so it will still be in the same column. I used 'sidebar-lower':

<div id="secondary" class="widget-area" role="complementary">
    <?php do_action( 'before_sidebar' ); ?>

    <?php if ( ! dynamic_sidebar( 'sidebar-1' ) ) : ?>
    <?php endif; // end sidebar-1 widget area ?>

    <?php if ( ! dynamic_sidebar( 'sidebar-lower' ) ) : ?>
    <?php endif; // end sidebar-lower widget area ?>

</div><!-- #secondary -->


来源:https://stackoverflow.com/questions/19334974/underscores-wordpress-theme-adding-second-sidebar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!