How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
To get term_id of current taxonomy, use the following code snippet $queried_object = get_queried_object(); $term_id = $queried_object->term_id;
Hooking save_post breaks check for term in added_term_relationship hook?
WP-CLI Add category as menu item main-menu
Cannot retrieve categories for post in The Loop
How to get taxonomy tree ids without running expensive loops
After a lot of searching and tests… Finally I’ve found a solution. Instead using get_terms_args filter, I’ve changed to parse_term_query action. My resulting code looks this way now: add_action(“parse_term_query”, “MyTheme_ParseTermQuery”, PHP_INT_MAX, 1); function MyTheme_ParseTermQuery(&$query) { $taxonomy = $query->query_vars[‘taxonomy’][0]; if($taxonomy == “edition”){ $query->query_vars[‘order’] = “ASC”; $query->query_vars[‘orderby’] = “meta_value_num”; $query->query_vars[‘meta_query’] = [[ ‘key’ => “_edition”, ‘type’ => … Read more
Include get_term_link inside search
Turns out someone had the same problem and answered their own problem here. wp_set_object_terms not accepting variable array Here’s my working solution for my problem: $image_category = array_map(‘intval’, $_POST[‘image_category’]); wp_set_object_terms($product->get_id(), $image_category, ‘product_cat’); Hope this helps someone else. Thanks for reading.
this will work: $terms = wp_get_object_terms( $post->ID, ‘wpsc_product_category’ ); foreach($terms as $term){ if($term->parent != 0){ // this category has a parent and its id is $term->parent } }