WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer
 $args = array(
    'post_type' => 'mobile_review',
    'taxonomy' => 'mobile_phone'

Is that what you're looking for?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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