WP-CLI Add category as menu item main-menu
WP-CLI Add category as menu item main-menu
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 } }
This is how the links are created in wp_generate_tag_cloud (wp-includes/category-template.php) foreach ( $tags as $key => $tag ) { $count = $counts[ $key ]; $real_count = $real_counts[ $key ]; $tag_link = ‘#’ != $tag->link ? esc_url( $tag->link ) : ‘#’; $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key; $tag_name = $tags[ $key … Read more
Try this <?php echo get_the_term_list($post->ID, ‘skills’, ‘<h5>Project Role</h5><ul><li> ‘, ‘</li><li>’, ‘</li></ul>’ ); ?>
Dealing with terms is known to be very heavy operation. The common tweak recommended is to use wp_defer_term_counting() to temporarily disable updating of terms count (which is stored persistently in database and so must be updated when you change terms).