Advertisement
davidakennedy

WordPress Sitemap with Custom Post Types

Jun 21st, 2011
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <h2 id="posts">My Post Type</h2>
  2.             <ul>
  3.             <?php
  4.             $terms = get_terms( 'my_taxonomy', 'orderby=name' );
  5.             foreach ($terms as $term) {
  6.             echo "<li><h3>".$term->name."</h3>";
  7.             echo "<ul>";
  8.             $args = array(
  9.                 'post_type' => 'my_posttype',
  10.                 'posts_per_page' => -1,
  11.                 'tax_query' => array(
  12.                     array(
  13.                         'taxonomy' => 'my_taxonomy',
  14.                         'field' => 'slug',
  15.                         'terms' => $term->slug
  16.                     )
  17.                 )
  18.             );
  19.             $new = new WP_Query($args);
  20.             while ($new->have_posts()) {
  21.             $new->the_post();
  22.             echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  23.             }
  24.             echo "</ul>";
  25.             echo "</li>";
  26.             } ?>
  27.             </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement