Sort categories by custom field in WordPress admin

For some reason the add_action( ‘pre_get_posts’, ‘category_custom_orderby’ ); hook isn’t working. Yes, and it’s because on the Categories admin page (where you can see the Categories list table), the list table uses WP_Term_Query and not WP_Query, hence the above hook (pre_get_posts) is not fired. So instead of the above add_action(), try using the parse_term_query hook … Read more

How can i change sort category view starting from child then parent, not alphabetically

To sort hierarchically, try adding a sorting function to your functions.php (or plugin). // This will sort and place everything in the $into array function sort_terms_hierarchically(Array &$cats, Array &$into, $parentId = 0) { foreach ($cats as $i => $cat) { if ($cat->parent == $parentId) { $cat->posts = array(); $into[$cat->term_id] = $cat; unset($cats[$i]); } } foreach … Read more

Conditional label Woocommerce archive [unsolved]

You need to access the Woo product loop, to output extra content on shop/archive pages (unless you use a custom template) Try something like this: add_action( ‘woocommerce_after_shop_loop_item’, ‘conditional_label’, 5 ); function conditional_label() { global $product; if (has_term( ‘new’, ‘product_cat’, $product->get_id())) { echo ‘<p class=”new-lable”>New</p>’; } } Not tested, but should get you in the right … Read more