Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My WP 3.6 has created a custom template using register_post_type() named movie. I inserted few movie via Admin Dashboard > Movie. For Permalink, I have set to Post Type, therefore, for example, movie1 (instance of Custom Post Type movie), the URL is:

http://example.com/wordpress/movie/movie1

If I want to show a list of movie with link http://example.com/wordpress/movie/, which custom template file has to be created?

I already have single.php, single-movie.php for displaying the movie1. But how about a list of movie ?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Firstly, there is the archive-POST_TYPE.php file, so in your case it would be archive-movie.php.
You find more information on that (and all the other templates) in the Template Hierarchy.

Secondly, you can just list your custom posts anywhere you want, using a separate query:

$args = array(
    'post_type' => 'movie',
    // maybe put some other settings here as well
);
$movies = new WP_Query($args);
if ($movies->have_posts()) {
    while ($movies->have_posts()) {
        $movies->the_post();
        // now work with `the_content`, `the_title` and the like...
    }
}
wp_reset_postdata();
share|improve this answer

Your Answer

 
discard

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.