Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.