Advertisement
deepbevel

list custom post type entries by category

Jul 9th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. //list terms in a given taxonomy (useful as a widget for twentyten)
  3. $taxonomy = 'productscat';
  4. $tax_terms = get_terms($taxonomy);
  5. ?>
  6. <ul>
  7. <?php
  8. foreach ($tax_terms as $tax_term) {
  9. echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
  10. }
  11. ?>
  12. </ul>
  13.  
  14.  
  15. <?php
  16. $args = array(
  17. 'post_type' => 'products',
  18. 'category' => product-test-cat-1,
  19. 'posts_per_page' => -1,
  20.  
  21.  
  22. );
  23. $loop = new WP_Query( $args );
  24.  
  25.  
  26. while ( $loop->have_posts() ) : $loop->the_post();
  27.  
  28. ?>
  29.  
  30. <a href="<?php the_permalink(); ?>"><?php the_title();?></a>
  31.  
  32. <?php echo '<div class="entry-content">';
  33. the_post_thumbnail('thumbnail');
  34. the_excerpt();
  35. echo '</div>';
  36. endwhile;
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement