Community Forums › Forums › Archived Forums › General Discussion › Respecting Genesis layout options in Woocomerce
Tagged: layout, WooCommerce
- This topic has 3 replies, 2 voices, and was last updated 8 years, 7 months ago by
Brad Dalton.
-
AuthorPosts
-
August 1, 2016 at 10:58 pm #190619
gregnumber1man
MemberHi.
Please bear with me on this one.
In the Genesis Connect for Woocommerce plugin, in archive-product.php, the following code allows the user to set the layout for the shop archive pages within the shop Edit Page screen.
add_filter( 'genesis_pre_get_option_site_layout', 'genesiswooc_archive_layout' ); function genesiswooc_archive_layout( $layout ) { global $shop_page_id; $layout = get_post_meta( $shop_page_id, '_genesis_layout', true ); return $layout; }
However, this code ignores the 'Default Layout set in Theme Settings' radio button. If this radio button is selected, the theme's default layout setting is used, not the user selected layout on the 'Theme Settings' page.
My inital solution to this issue is to replace the code in question with the following:
add_filter( 'genesis_pre_get_option_site_layout', 'my_function' ); function my_function( $layout ) { global $shop_page_id; if ( get_post_meta( $shop_page_id, '_genesis_layout', true ) == null ) { $layout = genesis_site_layout(); return $layout; } else { $layout = get_post_meta( $shop_page_id, '_genesis_layout', true ); return $layout; } }
However, this returns a 503 error. "503. Service Unavailable. The server is temporarily busy, try again later! Proudly powered by LiteSpeed Web Server".
The following code bypasses the error:
if ( get_post_meta( $shop_page_id, '_genesis_layout', true ) == null ) { add_filter( 'genesis_pre_get_option_site_layout', genesis_site_layout() ); } else { add_filter( 'genesis_pre_get_option_site_layout', 'my_function' ); } function my_function( $layout ) { global $shop_page_id; $layout = get_post_meta( $shop_page_id, '_genesis_layout', true ); return $layout; }
************************************
In summary, why does this work:
add_filter( 'genesis_pre_get_option_site_layout', genesis_site_layout( ) );
...while this generates a 503 error:
add_filter( 'genesis_pre_get_option_site_layout', 'my_function' ); function my_function( ) { return genesis_site_layout( ); }
Thanks.
August 2, 2016 at 12:31 am #190621Brad Dalton
ParticipantDid you copy the folder over to your child theme or are you modifying the plugin code?
August 2, 2016 at 1:24 am #190625gregnumber1man
MemberHi Brad,
Thanks for your reply.
I have tried both methods.
If I completely uninstall the plugin, I can replicate the issue by creating a my-child-theme/woocommerce/archive-product.php file.
Here are the contents of that file which will generate the 503 error:
<?php remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'woocommerce_content' ); add_filter( 'genesis_pre_get_option_site_layout', 'my_function' ); function my_function( $layout ) { global $shop_page_id; if ( get_post_meta( $shop_page_id, '_genesis_layout', true ) == null ) { $layout = genesis_site_layout(); return $layout; } else { $layout = get_post_meta( $shop_page_id, '_genesis_layout', true ); return $layout; } } genesis ();
If I replace the code above with the following code, everything works fine:
<?php remove_action( 'genesis_loop', 'genesis_do_loop' ); add_action( 'genesis_loop', 'woocommerce_content' ); if ( get_post_meta( get_option( 'woocommerce_shop_page_id' ), '_genesis_layout', true ) == null ) { add_filter( 'genesis_pre_get_option_site_layout', genesis_site_layout() ); } else { add_filter( 'genesis_pre_get_option_site_layout', 'my_function' ); } function my_function( $layout ) { $layout = get_post_meta( get_option( 'woocommerce_shop_page_id' ), '_genesis_layout', true ); return $layout; } genesis();
What I would like to know is: why am I getting a 503 error using the first method?
Regards,
Greg
August 2, 2016 at 7:53 am #190644Brad Dalton
ParticipantCan't you add 1 line of PHP like this to the template file:
add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' );
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.