Advertisement
tcelestino

List post of custom taxonomy

May 16th, 2012
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. <?php
  2.  
  3.                         $args = array(
  4.  
  5.                                 'order' => 'DESC',
  6.                                 'orderby' => 'name',
  7.                                 'hide_empty' => 0
  8.  
  9.                             );
  10.  
  11.                         $terms = get_terms('categoria', $args);
  12.                            
  13.  
  14.                     if($terms) {
  15.  
  16.                    
  17.                     ?>
  18.                     <ul class="lista-dicas">
  19.                         <?php $x = 0; foreach($terms as $term); { $x++;  
  20.  
  21.                             $term_name = $term->name;
  22.  
  23.                             var_dump($term);?>
  24.  
  25.  
  26.                         <li><a href="#"><i class="ico ico-<?php echo $x; ?>"></i> <?php echo $term_name; ?></a>
  27.  
  28.                             <?php
  29.  
  30.                             $query = array(
  31.                                 'post_type' => 'dicas',
  32.                                 'posts_per_page' => -1,
  33.                                 'taxonomy' => $term_name
  34.                             );
  35.  
  36.                             query_posts($query);
  37.  
  38.                             if(have_posts()) { ?>
  39.  
  40.                             <ul>
  41.                                 <?php while(have_posts()) { the_post(); ?>
  42.                                 <li><a href="<?php //the_permalink(); ?>" id="<?php the_ID() ?>"><?php the_title(); ?></a></li>
  43.                                 <?php } ?>
  44.                             </ul>
  45.                             <?php } wp_reset_query() ?>
  46.                         </li>
  47.                         <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement