I am slowly going mad trying to figure this out..

I want to list custom post type 'mobile_review' by custom taxonomy 'mobile_phone', as multipe custom post types share this taxonomy I need some way to segment.

So far I have this:

function get_terms_by_post_type($taxonomies,$args){

 $args = array(
    'post_type' => 'mobile_review'

// The query for posts of type 'mobile_review'
$the_query = new WP_Query( $args );

// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();

//get terms    
    //$mobs = wp_get_object_terms($post->ID,"mobile_phone"); 
     $mobs = get_terms('mobile_phone');
 $count = count($terms);
 if ( $count > 0 ){
 echo "<ul>";
 foreach ( $terms as $term ) {
   echo "<li>" . $term->name . "</li>";

 echo "</ul>";


// Reset Post Data


Am I close? I have been hacking back and forth for ages and getting nowhere.

Any help would be great! Thanks in advance.

2 Answers 2


Here's an example that will list all the mobile_review posts that have the term htc_desire_hd in the taxonomy mobile_phone :

$tax_query = array( 'relation' => 'AND' );

$tax_query[] = array( 
    'taxonomy' => 'mobile_phone', 
    'terms' => array('htc_desire_hd'),
    'field' => 'slug' 

$args = array(
    'post_type' => 'mobile_review',
    'tax_query' => $tax_query

$custom_loop = new WP_Query( $args ); 

if ( $custom_loop->have_posts() ) :

    while( $custom_loop->have_posts() ) : $custom_loop->the_post(); 



else :

    _e('Sorry, nothing here.');



Now you can have the phones reviews by phone model, you just need to change the phone names, pass the name from a form, URL, etc.

 $args = array(
    'post_type' => 'mobile_review',
    'taxonomy' => 'mobile_phone'

Is that what you're looking for?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.