Title: When does WordPress load archive.php and when single.php
Last modified: November 11, 2016

---

# When does WordPress load archive.php and when single.php

 *  Resolved [Liddika](https://wordpress.org/support/users/liddika/)
 * (@liddika)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/when-does-wordpress-load-archive-php-and-when-single-php/)
 * I am rewriting the URLs for a custom post type.
 *     ```
           // Add rewrite rule
           function custom_rewrite_basic() {
             add_rewrite_rule(
                       '^movies/([^/]*)/([^/]*)/?',
                       'index.php?post_type=movies&movie_id=$matches[1]',
                       'top'
                   );
           }
           add_action('init', 'custom_rewrite_basic');
       ```
   
 * However the above code only sends me to the archive page.
 * URL example: example.com/movies/157336/
    The ID is a custom field, and not the
   actual post ID.
 * When I rewrite the URL to `index.php?post_type=movies&movie_id=$matches[1]&name
   =$matches[2]` then wordpress loads the single.php
 * Yes I have read through [https://developer.wordpress.org/themes/basics/template-files/](https://developer.wordpress.org/themes/basics/template-files/)
   and [https://developer.wordpress.org/themes/basics/template-hierarchy/](https://developer.wordpress.org/themes/basics/template-hierarchy/)
   however it does not mention anything about what is required to request the single.
   php or archive.php page.
 * From trial and error it seems when the GET parameters `p` or `name` are available,
   then WordPress loads the single.php, otherwise it loads archive.php
 * I want wordpress to load the single.php or in this case single-movies.php without
   using `p` or `name` as URL parameters.
 * How can I tell wordpress to do that?
    -  This topic was modified 9 years, 7 months ago by [Liddika](https://wordpress.org/support/users/liddika/).

The topic ‘When does WordPress load archive.php and when single.php’ is closed to
new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Liddika](https://wordpress.org/support/users/liddika/)
 * Last activity: [9 years, 7 months ago](https://wordpress.org/support/topic/when-does-wordpress-load-archive-php-and-when-single-php/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
