Hi, its me again :). I am making an event listing system where i have a event post type with meta fields. In sidebar i am listing upcoming events.
When i place the code for upcoming events in sidebar it works. But i dont wanna put the codes in sidebar rather i want to put them in function.php as i have a plan to make a plugin/widget later for flexibility.
So, i have put all the codes in a function in function.php file and call it in sidebar. but php can't find the meta values!! it does find the title, permalinks but meta values are unset! it's looks too wired to me. Here is the code, let me know if i am doing something wrong or its a but. i am using wordpress 3.0.1
query_posts('post_type=event&order_by=start_date&order=DESC&meta_key=start_time&meta_compare=>&meta_value='.time());
if(have_posts()) : while(have_posts()) : the_post();
if(get_post_meta($post->ID, 'end_time', true)){
$end_time = get_post_meta($post->ID, 'end_time', true);
}else{
$end_time = "N/A";
}
if(get_post_meta($post->ID, 'start_time', true)){
$start_time = get_post_meta($post->ID, 'start_time', true);
}else{
$start_time = "N/A";
}
?>
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_title();?></a></h1>
<small><?php echo time_diff($start_time, $end_time); ?></small>
<?php
endwhile; endif;
update: it seems to find the meta values in query_posts. but not below it!