foreach wp_query and get_terms
-
I have problem with the loop in page. Here is my code:
<ul> <?php $terms = get_terms('product'); foreach ($terms as $term) { $views = new WP_Query(array('post_type' => 'project', 'post_per_page' => 20)); while ($views->have_posts()) : $views->the_post(); ?> <li class="rounded"> <?php if (function_exists('get_the_image')) $views_img = get_the_image( array( 'image_scan' => true, 'format' => 'array', 'size' => 'medium','width' => '128' ) ); ?> <a href="<?php echo get_term_link($term->slug, 'product'); ?>" title=""> <img src="<?php echo home_url( '/' ); ?>wp-content/uploads/timthumb.php?w=120&h=64&zc=1&src=<?php echo $views_img[url]; ?>" alt=""/> </a> </li> <?php endwhile; } wp_reset_query(); ?> </ul>
It must show the recent post from “product” custom taxonomy. And the “post permalink” is go to taxonomy category.
The problem is with the post. It’s showing double for each post with the random taxonomy category url.
I know that’s problem with the loop, but i don’t know how to fix it.
Sorry about my bad english.Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘foreach wp_query and get_terms’ is closed to new replies.