Order taxonomy terms in ASC order while generating dynamic post title using CRED

To get hierarchical taxonomy terms sort in a ASC order you need to add “orderby” clause with WP function: wp_get_post_terms(). you can use term_id with orderby clause. Could you please try following code:


add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {
if ($form_data['id']==XXXX) {
$term_list = wp_get_post_terms($post_id, 'listing-type', array("fields" => "names","orderby"=>"term_id"));
$auctiontype = join("-",$term_list);
$auctiondate = get_post_meta($post_id, 'wpcf-auction-ending', true);
$auctiondate = date('d-m-Y',$auctiondate);

$term_list= wp_get_post_terms($post_id, 'car-brand', array("fields" => "names","orderby"=>"term_id"));
$carbrand = join("-",$term_list);

$title= $auctiontype. ': le ' . $auctiondate. ' - ' . $carbrand;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}

Ticket URL: https://wp-types.com/forums/topic/get-custom-taxonomy-in-auto-title/#post-519488