2011-12-27 24 views

答えて

3

これは動作するはずです:

<?php 
    $args = array(
     'orderby'  => 'name', 
     'order'   => 'ASC', 
     'hide_empty' => 1, 
     'taxonomy'  => 'post_tag', //change this to any taxonomy 
    ); 
    foreach (get_categories($args) as $tax) : 
     $args = array(
      'post_type'   => 'post', //change to your post_type 
      'posts_per_page' => -1, 
      'orderby'   => 'title', 
      'orderby'   => 'ASC', 
      'tax_query' => array(
       array(
        'taxonomy' => 'post_tag', //change this to any taxonomy 
        'field'  => 'slug', 
        'terms'  => $tax->slug 
       ) 
      ) 
     ); 
     if (get_posts($args)) : 
    ?> 
     <h2><?php echo $tax->name; ?></h2> 
     <ul> 
      <?php foreach(get_posts($args) as $p) : ?> 
       <li><a href="<?php echo get_permalink($p); ?>"><?php echo $p->post_title; ?></a></li> 
      <?php endforeach; ?> 
     </ul> 
    <?php 
     endif; 
    endforeach; 
?> 
関連する問題