Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this query which is working fine but I can not get it to exclude child terms and include only parent terms. This is what I have so far --

<?php
$custom_terms = get_terms('videoscategory');
$other_custom_terms = get_terms('product_category');

foreach ($custom_terms as $custom_term) {
foreach ($other_custom_terms as $other_custom_term) {
    wp_reset_query();
if($term->parent < 1) {
    $args = array('post_type' => 'product', 'orderby' => 'title', 
                'order' => 'asc',
        'tax_query' => array(
  'relation' => 'AND',
'orderby' => 'title', 
                'order' => 'asc',
    array(
        'taxonomy' => 'product_category',
        'field' => 'slug',
        'terms' => $other_custom_term->slug,
'orderby' => 'title', 
                'order' => 'asc',
    ),
            array(
                'taxonomy' => 'videoscategory',
                'field' => 'slug',
                'terms' => $custom_term->slug,
                'include_children' => false
            ),
        ),
  );

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

        <div class="box <?php echo $custom_term->slug; ?>" style="float:left;width:100%;">
        <h1 style="margin-top:10px;font-size:20px;font-weight:bold;"><?php echo $custom_term->name;?></h1>

      <?php       
      while($loop->have_posts()) : $loop->the_post(); ?>

            <h2><a href="<?php echo get_permalink() ?>"><?php echo get_the_title(); ?></a></h2>
      <?php  endwhile; ?>
      </div>
     <?php   
     }
}
}
} ?>
share|improve this question
    
can anyone please help me????? –  mygm26 Apr 21 '13 at 5:05
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.