Skip to content

Instantly share code, notes, and snippets.

@RadGH
Created July 22, 2015 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RadGH/7c6b0f845e2f591a3c5e to your computer and use it in GitHub Desktop.
Save RadGH/7c6b0f845e2f591a3c5e to your computer and use it in GitHub Desktop.
Woocommerce - Sortable custom taxonomy
<?php
// This is so easy, it's embarassing that I took 20 minutes to find it.
// "Catalog" is a custom taxonomy.
function make_catalog_sortable( $sortables ) {
$sortables[] = 'catalog';
return $sortables;
}
add_filter( 'woocommerce_sortable_taxonomies', 'make_catalog_sortable' );
@alhoseany
Copy link

you can then get the sortable taxonomies like this:
$terms = get_the_terms($post->ID, 'catalog'); if (!empty($terms) && is_array($terms)) { $post_terms = array(); foreach ($terms as $term) { $post_terms[] = $term->term_id; } $categories = get_terms('catalog', array( 'orderby' => 'name', 'menu_order' => 'asc', 'include' => $post_terms, )); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment