loop not showing up when using a custom page template

You haven’t created a query to return your post index results.

Let me back up…

In WordPress something called the “Main” query runs very early in the page load, and well before your template files load. That query retrieves the posts to display and also (more or less) determines which template file to use to display the results. That “Main” query retrieves different results based upon the URL requested, or you’d get exactly the same thing on all pages. The results on the index page are going to be different from the results on your custom page– the results on your custom page is going to be the single page itself and not the index. That means that if you want an index on some secondary page, you need to create a query.

It could be as simple as:

$p = new WP_Query(array('post_type' => 'post'));
if ($p->have_posts()) {
  while ($p->have_posts()) {
    $p->the_post();
    // Display
  }
}

However, the peculiarities of your theme could complicate things, so be warned.

Leave a Comment