Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimcoleman/68973a03d1dcd07b1f14f44f60e6c2ec to your computer and use it in GitHub Desktop.
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.
<?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