Skip to content

Instantly share code, notes, and snippets.

@neilgee
Created October 1, 2017 07:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save neilgee/7a4dc9590bce058285b7f7c2b6e0e9d4 to your computer and use it in GitHub Desktop.
Save neilgee/7a4dc9590bce058285b7f7c2b6e0e9d4 to your computer and use it in GitHub Desktop.
WooCommerce Product Category Dropdown in Archive
<?php // <~ don't add me in
add_action( 'widgets_init', 'wb_extra_widgets' );
/**
* Register new Widget area for Product Cat sort dropdown.
*/
function wb_extra_widgets() {
register_sidebar( array(
'id' => 'prod_sort',
'name' => __( 'Product Cat Sort', 'themename' ),
'description' => __( 'This site below Shop Title', 'themename' ),
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3>'
) );
}
add_action( 'woocommerce_before_shop_loop','wb_prod_sort' ); // Hook it after headline and before loop
/**
* Position the Product Category Sort dropdown.
*/
function wb_prod_sort() {
if ( is_active_sidebar( 'prod_sort' ) ) {
dynamic_sidebar( 'prod_sort' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment