Reputation: 1832
I'm outputting a bunch of custom post types within a page. How do I get all the titles of the posts within this current page?
Upvotes: 2
Views: 18390
Reputation:
Right before 'The Loop', you might as well just use:
<?php query_posts('post_type=your_custom_post_type');?>
Upvotes: 1
Reputation: 697
You should look at WP_Query() for outputting custom post types. The code below gets all of your custom posts of the type 'custom_post_type', puts them in a variable called $loop and iterates through it, outputting the title of each post contained within.
<?php
// Get the 'Profiles' post type
$args = array(
'post_type' => 'custom_post_type',
);
$loop = new WP_Query($args);
while($loop->have_posts()): $loop->the_post();
the_title();
endwhile;
wp_reset_query();
?>
There are other arguments that you can pass in to WP_Query() to make it more suitable for your needs. Documentation can be found here.
Upvotes: 7