Your code isn't working well because it uses both get_posts()
and query_posts()
functions.
However, for your custom query I suggest using the WP_Query
object (read more in Codex).
Try this:
<?php
$args = array(
'meta_key' => 'event_date', // name of custom field
'orderby' => 'meta_value_num',
'order' => 'ASC',
'cat' => '23'
);
$event_query = new WP_Query( $args );
// The Loop
if ( $event_query->have_posts() ) {
while ( $event_query->have_posts() ) {
$event_query->the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="entry">
<?php the_post_thumbnail( 'whatson-thumb' ); ?>
<h2 class="pagetitle">
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</h2>
<?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>
<?php the_excerpt(); ?>
</div>
</div>
<?php
}
}else{
echo '<h2>Not Found</h2>';
}
// Restore original Post Data
wp_reset_postdata();
?>