Support » Fixing WordPress » Custom Post Type list posts

  • Resolved WatsonN


    I know there is a way but I have not been able to get it right, yet.
    I have four custom post types and I want to put each one into a list of all their post titles. I know I need the_title() and the_permalink() But how do I specify which post type to pull from?

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you are using WP_Query you could use the post_type parameter:

    $query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'movie', 'book' ) ) );

    Or for a single post type:

    $query = new WP_Query( array( 'post_type' => 'book' ) );

    Thank you, that was exactly what I needed!

    $query = new WP_Query( array( 'post_type' => array( 'labs', 'activities', 'projects', 'testreview' ) ) );
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li><a href="';
    	echo '">';
    	echo '</a></li>';

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Type list posts’ is closed to new replies.