{"id":1627,"date":"2017-08-18T22:07:09","date_gmt":"2017-08-18T20:07:09","guid":{"rendered":"http:\/\/www.kavdesign.net\/blog\/?p=1627"},"modified":"2017-08-18T22:16:04","modified_gmt":"2017-08-18T20:16:04","slug":"how-to-add-a-sidebar-to-storefront-woocommerce-child-theme","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-add-a-sidebar-to-storefront-woocommerce-child-theme\/","title":{"rendered":"How to Add a Sidebar to Storefront WooCommerce Child Theme"},"content":{"rendered":"<p>First you need to create a child theme called <em>storefront-child<\/em>\u00a0if you don&#8217;t have one. Refer to\u00a0https:\/\/codex.wordpress.org\/Child_Themes<\/p>\n<p>For <em>storefront-child<\/em> you don&#8217;t need to enqueue child theme stylesheet &#8211; it is done by the parent theme class-storefront.php<\/p>\n<p><!--more--><\/p>\n<p>1. Copy sidebar.php from your storefront theme and place it in your child theme. Change the name of the file to sidebar-yourNewSidebar.php and alter the code on that page for your new sidebar name.<\/p>\n<p><code>&lt;?php<\/code><br \/>\n<code> \/**<\/code><br \/>\n<code> * The sidebar containing the second sidebar area.<\/code><br \/>\n<code> *<\/code><br \/>\n<code> * @package storefront<\/code><br \/>\n<code> *\/<\/code><\/p>\n<p><code>if ( ! is_active_sidebar( 'sidebar2' ) ) {<\/code><br \/>\n<code>\u00a0 \u00a0 return;<\/code><br \/>\n<code> }<\/code><br \/>\n<code> ?&gt;<\/code><\/p>\n<p><code>&lt;div id=\"secondary\" class=\"widget-area\" role=\"complementary\"&gt;<\/code><br \/>\n<code>\u00a0 \u00a0 &lt;?php dynamic_sidebar( 'sidebar2' ); ?&gt;<\/code><br \/>\n<code> &lt;\/div&gt;&lt;!--\u00a0#secondary\u00a0--&gt;<\/code><\/p>\n<p>2. In functions.php file of child theme, add the following code to register your sidebar (change the names to what your sidebar is called):<\/p>\n<p><code>add_action( 'widgets_init', 'register_new_sidebars' );<\/code><\/p>\n<p><code>function register_new_sidebars() {<\/code><\/p>\n<p><code>\u00a0 register_sidebar(array(<\/code><br \/>\n<code>\u00a0 \u00a0 'id' =&gt; 'sidebar2',<\/code><br \/>\n<code>\u00a0 \u00a0 'name' =&gt; __( 'Sidebar 2', 'storefront' ),<\/code><br \/>\n<code>\u00a0 \u00a0 'description' =&gt; __( 'Sidebar 2.', 'storefront' ),<\/code><br \/>\n<code>\u00a0 \u00a0 'before_widget' =&gt; '&lt;div id=\"%1$s\" class=\"widget %2$s\"&gt;',<\/code><br \/>\n<code>\u00a0 \u00a0 'after_widget' =&gt; '&lt;\/div&gt;',<\/code><br \/>\n<code>\u00a0 \u00a0 'before_title' =&gt; '&lt;h4 class=\"widgettitle\"&gt;',<\/code><br \/>\n<code>\u00a0 \u00a0 'after_title' =&gt; '&lt;\/h4&gt;',<\/code><br \/>\n<code>\u00a0 ));<\/code><br \/>\n<code> }<\/code><\/p>\n<p>3. Find the template files that you want to override and copy them to your child theme and add your new sidebar:<\/p>\n<p><code>get_sidebar('sidebar2');<\/code><\/p>\n<p>&#8212;&#8212;<\/p>\n<p>More info &#8211;\u00a0https:\/\/www.youtube.com\/watch?v=7p2DCPkleZI<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First you need to create a child theme called storefront-child\u00a0if you don&#8217;t have one. Refer to\u00a0https:\/\/codex.wordpress.org\/Child_Themes For storefront-child you don&#8217;t need to enqueue child theme<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-add-a-sidebar-to-storefront-woocommerce-child-theme\/\">Continue reading<span class=\"screen-reader-text\">How to Add a Sidebar to Storefront WooCommerce Child Theme<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9,82],"tags":[209,433],"class_list":["post-1627","post","type-post","status-publish","format-standard","hentry","category-coding","category-wordpress","tag-sidebar","tag-woocommerce","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/1627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=1627"}],"version-history":[{"count":4,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/1627\/revisions"}],"predecessor-version":[{"id":1631,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/1627\/revisions\/1631"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=1627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=1627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=1627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}