Home Forums General Issues Order by (sort) taxonmy fields using taxonmy custom field value


Order by (sort) taxonmy fields using taxonmy custom field value

  • I have taxonomy:-shop_vendor with multiple vendors and every vendor have two radio buttons 1)Wellness 2)Dietitian and each vendor have selected one radio button at list.

    If i have 6 vendors in taxonomy:-shop_vendor which 3 have have selected 1)Wellness and other 3 have selected 2)Dietitian radio button in back end form.

    so i want display shop_vendor fields in two parts 1:Wellness for 3 vendors and 2:Dietitian for 3 vendors

    in bellow code i have try to edit but its not work.currently this code displaying vendor which have woo commerce product.

    add_shortcode( ‘list_vendors’, ‘wc_list_vendors_shortcode’ );
    function wc_list_vendors_shortcode( $atts ) {
    $vendors = ”;
    $terms = get_terms( ‘shop_vendor’ );
    foreach ( $terms as $term ) {
    $term_link = get_term_link( $term, ‘shop_vendor’ );
    if ( is_wp_error( $term_link ) )
    $vendors .= ‘<h2>‘ . $term->name . ‘</h2>’;
    $vendors .= ” . $term->description . ‘

    return $vendors;

    the answer will be very appreciative.

  • also you can check this question for more details

    click here

  • Hi @bcsplsanjay,

    Thanks for the post.

    Since you are using single value selection(Radio buttons) in your taxonomy, you do not need a foreach loop.

    The code will look like so:

    $term = get_field('taxonomy_field_name');
    if( $term ): ?>
    	<h2><?php echo $term->name; ?></h2>
    	<p><?php echo $term->description; ?></p>
    <?php endif; ?>
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Order by (sort) taxonmy fields using taxonmy custom field value’ is closed to new replies.