I have a blog theme that I created which shows one post per page. To do this I simply set up single.php the way I wanted, and I have some code that links the 'blog' item in the nav to the latest blog post, and it all works fine. Yay.

Now the client wants to see 3 posts per page, so I created a new template-blog.php file, and then created a page a /blog to display three posts in a row.

My template-blog.php file starts with The Loop:

    if ( have_posts() ) {
        while ( have_posts() ) {

Yet it never actually gets any posts, so the page at /blog displays a blank blog post.

How can I get Wordpress to give this template 3 blog posts?

I tried just upping the # of blog posts per page in Settings/Reading to 3, but that did nothing. Then I set my "Posts" page (also in Settings/Reading) to the Blog template, and now it uses the content.php file to display one blog post (poorly) and completely ignores my template-blog.php file. I didn't even know about the content.php file before this?!

I think the answer is that I probably shouldn't be using a template-blog.php file at all, and instead I should be changing some other file(s) to display three posts at once. I can work on editing content.php so it displays one single post correctly, but the rest of the page design still needs to be there (like the special header I have for the blog, etc, currently in template-blog.php). How?

  • Can you show us all the code in template-blog.php? – Charles Clarkson Sep 4 '13 at 20:33
  • You're looking at it-- the code starts with The Loop (as I posted above). There's obviously other HTML on the page to draw the blog-specific header and footer, etc, but none of that has to do with Wordpress. – Eric Sep 4 '13 at 20:35
  • Where are you setting up the query arguments to tell the loop which posts to display on this page? – Charles Clarkson Sep 4 '13 at 20:37
  • I see now, that was the problem :-) – Eric Sep 4 '13 at 20:53

before start your posts loop in a custom page template you need to get posts from database by using wp_query() or get_posts() do some thing like this.

$args = array(
    'posts_per_page' => 3

$my_query = new WP_Query($args);

// now start your loop
if ( $my_query->have_posts() ) {
    while ( $my_query->have_posts() ) {
        // print post data, title, content .etc


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.