Created
July 22, 2015 06:49
-
-
Save RadGH/7c6b0f845e2f591a3c5e to your computer and use it in GitHub Desktop.
Woocommerce - Sortable custom taxonomy
This file contains 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 | |
// 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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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, )); }