Make all WooCommerce Pages Full Width in Genesis (including Product Pages)

You can set all of WooCommerce pages including all product pages to be full width content inside of a Genesis Theme by adding a function and filter to your functions.php file.

<?php
//do not copy above opening php tag when pasting into a functions.php file
//Full Width Pages on WooCommerce
function themeprefix_cpt_layout() {
if( is_page ( array( 'cart', 'checkout' )) || is_shop() || 'product' == get_post_type() ) {
return 'full-width-content';
}
}
add_filter( 'genesis_site_layout', 'themeprefix_cpt_layout' );
view raw woopages.php hosted with ❤ by GitHub

So in the above the WooCommerce shop, cart and checkout pages are targeted in an array plus the custom post type ‘Products’ which is the page type all the products are used for output.

Similarly if you wanted to add a sidebar to all the WooCommerce pages you would use:

<?php
//do not copy above opening php tag when pasting into a functions.php file
//Full Width Pages on WooCommerce
function themeprefix_cpt_layout() {
if( is_page ( array( 'cart', 'checkout' )) || is_shop() || 'product' == get_post_type() ) {
return 'content-sidebar';
}
}
add_filter( 'genesis_site_layout', 'themeprefix_cpt_layout' );

Or alternatively use the other layout options in the return

  • content-sidebar-sidebar
  • sidebar-sidebar-content
  • sidebar-content-sidebar

Also make sure you are using the Genesis Connect for WooCommerce Plugin.

Here is some further info on selecting the various WooCommerce pages with PHP conditional statements.

5 Comments

  1. David on January 17, 2017 at 10:18 am

    I found the problem in Woocommerce.
    You have to add this line:
    remove_action(‘woocommerce_sidebar’, ‘woocommerce_get_sidebar’);

  2. David on January 17, 2017 at 10:15 am

    If it does not work, what could it be the problem?

  3. Gary Cheeseman on October 19, 2016 at 7:20 am

    Awesome. I’ve look for a fix to remove the sidebar from all woocommerce pages and this works a treat.

  4. Karla Archer on February 12, 2016 at 8:09 pm

    Perfect — thank you! This is the code I needed!

  5. Nick on October 8, 2015 at 9:13 pm

    Thanks again guys!

Leave a Comment





%d bloggers like this: