get tag_ID from post_type taxonomy code example

Example: how to get texonomy catogory wise post

$custom_terms = get_terms('custom_taxonomy');

foreach($custom_terms as $custom_term) {
    wp_reset_query();
    $args = array('post_type' => 'custom_post_type',
        'tax_query' => array(
            array(
                'taxonomy' => 'custom_taxonomy',
                'field' => 'slug',
                'terms' => $custom_term->slug,
            ),
        ),
     );

     $loop = new WP_Query($args);
     if($loop->have_posts()) {
        echo '

'.$custom_term->name.'

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

Tags:

Misc Example