I have the following code which is supposed to pull the last post with the avatar photo on the front page.
<?php $types[0] = 'post';
$types[1] = 'page';
foreach ($types as $type) {
$args=array(
'orderby' => 'date',
'order' => 'DESC',
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => 1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'Latest ' . $type ;
while ($my_query->have_posts()) : $my_query->the_post();
echo get_avatar( get_the_author_email(), '80');
the_date();
the_content();
endwhile;
}
} wp_reset_query(); ?>
It does but posts_per_page => 1 doesn't really seem to work as I get a post and a page? I only need the last post. Any suggestions please?
Removing $types[1] = 'page'; doesn't work, using $types = 'post'; neither.