$wp_query initiation?

I’m wondering when does WordPress initiate its main query which sets the $wp_query and enable us to use has_posts() and the_post() functions. If I create a page using archive template, how does it know how to set its query?

I’m looking at the archive.php in one of the WordPress default themes. They have an archive page but it just calls get_header() and has_posts(), so that means the query is already set. So WordPress routes the url to use the custom post type param in the URL?

If I choose to make custom archive pages, where do I modify the main query? In the new archive template file?

Read more here: $wp_query initiation?

Leave a Reply

Your email address will not be published. Required fields are marked *