I'm developing a wordpress theme that uses a static page as front page.
My wordpress is configured to use "Home" page as its front_page and "Blog" page to show the blog posts.
When i try to use the loop on my "Blog" page to list the posts i get a odd behavior, the loop runs fine but any method to get the post information returns an empty string.
Sample code:
if (have_posts()) {
while(have_posts()) {
the_post();
$posts[$index] = array(
'title' => get_the_title(),
'permalink' => get_permalink(get_the_ID()),
'content' => get_the_content(),
'day' => get_the_date('j'),
'month' => get_the_date('M')
);
$index++;
}
}
If i have 5 posts that yould return me an array with 5 elements, all of them with empty strings as the values.
If i add query_posts('posts_per_page=5');
. it works, but that shouldn't be needed.
What am i missing?
You can check the complete source code on github: https://github.com/albertein/coltsintheme
Thank you
UPDATE: Even if i avoid using a static page as front page (delete front-page.php and configure wp con Settings>Reaging) I'm getting the same results which seems weird to me, it seems I'm missing something.
blog.php
ashome.php
, and renamemain.php
asfront-page.php
, and just let WordPress handle the template laoding? (Also: yourindex.php
won't work outside of the Front Page and the Blog Posts Index. Is this be design?<?
should be<?php