WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I create a nav like those generated by wp_nav_menu which lists all the posts in a specific custom post type?

For example, I have CPT "section1" and I'd like to have the menu list all posts which are of type "section1". I've been searching the internet for three days now with no answer. Can anyone point me in the right direction?

I'm lost here, help!

share|improve this question

There are several ways to do this. Unless you are only going to have a few posts of type 'section1' then I would advise against listing them all.


Using the WP_Query() option:

<?php $posts = new WP_Query( array( 'post_type' => 'section1', 'posts_per_page' => -1 ) ); ?>

<?php while( $posts->have_posts() ) : $posts->the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>

<?php wp_reset_postdata(); ?>

Hope that helps!

If you are looking to dynamically create a nav-menu from the posts of a specific category, let's say having the slug 'featured', then replace 'post_type' => 'section1' with 'category_name' => 'featured'

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.