Created
January 31, 2024 12:58
-
-
Save kimcoleman/68973a03d1dcd07b1f14f44f60e6c2ec to your computer and use it in GitHub Desktop.
Add a sidebar to the entire WooCommerce shop and product pages using the Memberlite theme.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_custom_memberlite_woocommerce_hooks() { | |
// Remove Memberlite hooks | |
remove_action( 'woocommerce_before_main_content', 'memberlite_woocommerce_before_main_content', 10 ); | |
remove_action( 'woocommerce_after_main_content', 'memberlite_woocommerce_after_main_content', 10 ); | |
// Add custom WooCommerce hooks | |
add_action( 'woocommerce_before_main_content', 'my_custom_memberlite_woocommerce_before_main_content', 10 ); | |
add_action( 'woocommerce_after_main_content', 'my_custom_memberlite_woocommerce_after_main_content', 10 ); | |
// Add back WooCommerce sections handled by the theme | |
add_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 ); | |
} | |
add_action( 'init', 'my_custom_memberlite_woocommerce_hooks' ); | |
// Wrapping html for custom Memberlite WooCommerce styling | |
function my_custom_memberlite_woocommerce_before_main_content() { | |
echo '<div id="primary" class="medium-8 columns content-area">'; | |
echo '<main id="main" class="site-main" role="main">'; | |
} | |
function my_custom_memberlite_woocommerce_after_main_content() { | |
echo '</main></div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment