From problem to problem, disco to disco :P
My template requires that i print out headlines of 3 last blogposts in the header of my template. Its single page layout so those blogposts will link to posts that will be on page anyway - just somewhere down the line...
Since im complete wordpress newbie - i've already required help with creating this whole single page layout:
Modified home page query does not yield expected results
Long story short - i created app hook, that changes original query to include all pages. These blogposts need to be taken care of before we get to parsing the pages.
What i tried - following some examples i set up something like this:
<?php
$args = array(
'orderby' => 'ID',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish',
);
$children = get_pages($args);
foreach( $children as $post ){
setup_postdata($post);
get_template_part( 'header', 'blogheader' );
}
wp_reset_postdata();
?>
Yes the query does not include the posts limit 3 - but so be it. What this gives me - exactly nothing. If i comment everything out from those args, then i get my main query. Even just one argument, like 'post_type' => 'post' - i get nothing.
This led me into thinking that all those args are just modifying the original main query, not creating new one. Fine. I replaced get_pages($args)
with new WP_Query( $args );
. Now i got funny results - whole load of posts - even though i actually have just one, original, "hello world" post. It prints out even posts that have no title (im guessing they are drafts or something, even though i have not created any draft blogposts).
So what i want - i thought that setting post_type to post will give me blogposts only - i was wrong. What parameters do i have to set to get only published blogposts, sorted by id?
Alan