Get get_terms alphabetically

Maybe try tu use name__like as MySQL LIKE : $args = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘name__like’ => ‘b%’, ‘number’ => ’20’, );

delete term from taxonomy and assign in new one

wp_update_term() doesn’t changes taxonomy. It just updated the existing taxonomy. Say the below code- $update = wp_update_term( 1, ‘category’, array( ‘name’ => ‘Uncategorized Renamed’, ‘slug’ => ‘uncategorized-renamed’ ) ); if ( ! is_wp_error( $update ) ) { echo ‘Success!’; } This code finds the category which ID is 1, then updates it to the name … Read more

set terms to category and subcategory

I figured it out first set the terms to post through wp_set_object_terms and then run a update query in term_taxonomy table and set parent id of the the second term to first term. $taxo = wp_set_object_terms( $news_arr[0], utf8_encode($news_arr[2]), ‘vehicle_models’, $append = false ) ; $child = wp_set_object_terms( $news_arr[0], utf8_encode($news_arr[3]), ‘vehicle_models’, $append = true ) ; … Read more

List Top 5 taxonomy terms based on number of post

Here I’ve written a SQL query based function for you. You can use it to also for getting the top taxonomy terms based on post date range. Here it is- function the_dramatist_get_taxonomy_based_on_date_range_and_post_count( $args = array() ) { global $wpdb; $default_args = array( ‘taxonomy’ => ‘category’, ‘start_date’ => date(‘Y-m-d’), ‘end_date’ => date(‘Y-m-d’, strtotime(‘tomorrow’)), ); $args = … Read more

Getting terms to have space between them

You can either concatenate your call to echo with a space or newline. Space: <?php $terms = get_the_terms($property[‘ID’], ‘property_sub_type’); if(!empty($terms)){ foreach($terms as $value){ echo $value->name . ” “; } } ?> Newline: <?php $terms = get_the_terms($property[‘ID’], ‘property_sub_type’); if(!empty($terms)){ foreach($terms as $value){ echo $value->name . “\n”; } } ?>