bhubbard
3/9/2015 - 5:25 PM

Wordpress loop of all custom post types and posts

Wordpress loop of all custom post types and posts

/*
  Loop thru all Custom Post Types
  foreach( get_post_types( array('public' => true) ) as $post_type ) {
  if ( in_array( $post_type, array('post','page','attachment') ) )
    continue;

  $pt = get_post_type_object( $post_type );

  echo '<div class="row sitemap-section"> <div class="col-sm-12">';
  echo '<h4>'.$pt->labels->name.'</h4>';
  echo '<ul>';

  query_posts('post_type='.$post_type.'&posts_per_page=-1');
  while( have_posts() ) {
    the_post();
    echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  }

  echo '</ul>';
  echo '</div></div>';
}