I have multiple loops on my home page. I am trying to display custom fields in each loop. But some of them are not showing. Any idea, why? Here is the code:
//check for Featured Events here
$featured = new WP_Query (array(
'category_name' => 'Featured Events',
'posts_per_page' => 2)
);
if ($featured -> have_posts()) {
while ($featured-> have_posts()) : $featured -> the_post(); ?>
<h2 class="featured"> <?php the_title(); ?> </h2>
<h3 class="featured">
<?php echo get_post_meta($post->ID, 'Date', true); ?> </h3>
<h4 class="featured">
<?php echo get_post_meta($post->ID, 'Start Time', true); ?>
<?php if ( get_post_meta($post->ID, 'End Time', true) != "") { ; ?>
-
<?php echo get_post_meta($post->ID, 'End Time', true); }?> </h4>
<!--only print sponsor if value there -->
<?php if ( get_post_meta($post->ID, 'Sponsor', true) != "") { ; ?>
<h5 class="featured">
<?php echo get_post_meta($post->ID, 'Sponsor', true); ?></h5>
<?php }; ?>
<?php if ( get_post_meta($post->ID, 'Cost', true) != "") { ; ?>
<p class="cost">
<?php echo 'Cost: '. get_post_meta($post->ID, 'Cost', true); ?> </p> <?php };
if ( get_post_meta($post->ID, 'Location', true) != "") { ; ?>
<h6 class="featured">
<?php echo 'Location: '. get_post_meta($post->ID, 'Location', true); ?>
</h6>
<?php };
global $more;
$more = 0;
the_content('Read more please');
if ( get_post_meta($post->ID, 'link', true) != "") { ; ?>
<p> <a href="
<?php echo get_post_meta($post->ID, 'link', true); ?> "
> Click here for more information </a> </p>
<?php } endwhile;
}
wp_reset_query(); ?>
</div> <!-- content_inner -->
</div> <!-- content -->
</div> <!-- end 2 column wrap div -->
<div id="lftcol">
<div id="lcol_inner">
<?php
$ann_query = new WP_Query (array(
'category_name' => 'announcement',
'orderby'=> 'modified',
'posts_per_page' => 5) );
if ($ann_query -> have_posts()) {
while ($ann_query-> have_posts()) : $ann_query -> the_post();
if( $post->ID == $do_not_duplicate ) continue; //This is the Magic Line
// echo 'NON urgent announcement should follow '; ?>
<h2 class="featured"> <?php the_title(); ?> </h2>
<?php
//The code must be inserted ahead of the call the_content, but AFTER the_post()
global $more;
$more = 0; ?>
<h3 class="featured">
<?php echo get_post_meta($post->ID, 'Date', true); ?>
</h3>
<h4 class="featured">
<?php echo get_post_meta($post->ID, 'Start Time', true); ?>
<?php if ( get_post_meta($post->ID, 'End Time', true) != "") { ; ?>
-
<?php echo get_post_meta($post->ID, 'End Time', true); }?>
</h4>
<?php if ( get_post_meta($post->ID, 'Location', true) != "") { ; ?>
<h6 class="featured">
<?php echo 'Location: '. get_post_meta($post->ID, 'Location', true); ?>
</h6>
<?php };
the_content('Read more please');
if ( get_post_meta($post->ID, 'link', true) != "") { ; ?>
<p> <a href="
<?php echo get_post_meta($post->ID, 'link', true); ?>
" > Click here for more information </a> </p>
<?php }
endwhile; }
wp_reset_query(); ?>
</div>
</div>