My archive.php starts like this: get_header(); ?> <?php if( have_posts() ): ?> <div id="container" class="portfolio-wrapper"> <?php while( have_posts() ): the_post(); ?> I'm curious... where is the actual WP Query made? For example when I press on a Category or on an Archive link, I get to this page, but where's the actual select done? More specifically, I'm curious where the first query is created (in what file), since the above only **uses** a query which was already made somewhere. I'm asking because I want to create a custom archive (using a shortcode with posts ids in it) and I want to decide what is the best approach to do that :).