I've read several examples of how to do this but I still can't get it to work - each time I use get_posts() it seems to only keep and display the first set of results.
loop.php
function home_index() {
global $post;
echo '<ul>';
$args = array(
'numberposts' => 3,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'gp_news',
'post_status' => 'publish',
'meta_key' => '_thumbnail_id',
'meta_value' => 1,
'meta_compare' => '>='
);
$myposts = get_posts( $args );
foreach( $myposts as $post ) {
setup_postdata($post);
echo '<li>';
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'homepage-thumbnail' );
}
?>
<h1>news <a href="<?php the_permalink(); ?>" title="Permalink to <?php esc_attr(the_title()); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Continue...</a>
<?php
echo '</li>';
}
$args = array(
'numberposts' => 1,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'gp_competitions',
'post_status' => 'publish',
'meta_key' => '_thumbnail_id',
'meta_value' => 1,
'meta_compare' => '>='
);
$myposts = get_posts( $args );
foreach( $myposts as $post ) {
setup_postdata($post);
echo '<li>';
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'homepage-thumbnail' );
}
?>
<h1>competition <a href="<?php the_permalink(); ?>" title="Permalink to <?php esc_attr(the_title()); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<?php the_excerpt(); ?>
<a href="<?php the_permalink(); ?>">Continue...</a>
<?php
echo '</li>';
}
echo '</ul>';
}
var_dump()of the$mypostsvariables say? – Geert May 1 '11 at 6:14