• helllo i created custom post type and select taxonomy for custom post type i want to dispaly that how can i change this code my code is :

    $custom_terms = get_terms(‘mytaxonomy’);

    foreach($custom_terms as $custom_term) {
    // wp_reset_query();
    $args = array(‘post_type’ => ‘testimonials’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘mytaxonomy’,
    ‘field’ => ‘slug’,
    ‘terms’ => $custom_term->slug,
    ),
    ),
    );

    $loop = new WP_Query($args);
    if($loop->have_posts()) {
    echo ‘<h2>’.$custom_term->name.'</h2>’;

    while($loop->have_posts()) : $loop->the_post();
    echo ‘‘.get_the_title().’‘;
    endwhile;
    }
    }

Viewing 1 replies (of 1 total)
  • Thread Starter viralm

    (@viralm)

    I tried this but when i selected two custom taxonomy in post its display two time post title why?

Viewing 1 replies (of 1 total)
  • The topic ‘Dispaly taxonomy using custom post type’ is closed to new replies.