0

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 ?

1

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();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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