Question

I have the following query in WordPress to call custom post meta, everything is working fine, with one exception, whichever query is second is echoing nothing. Sorry for the WordPress post, but for those unfamiliar the 'get_post_meta($post->ID' is retrieving the post ID for the first one and then echoing the same for the second, I need to close the first query but don't know how.

            <h3 class="body_heading">
            <?php $soon_events = get_post_meta($post->ID, 'coming_soon_events', true); if ($soon_events) : echo $soon_events; endif; ?>
            </h3>   

        <h3 class="body_heading clear">
            <?php $feat_events = get_post_meta($post->ID, 'featured_events', true); if ($feat_events) : echo $feat_events; endif; ?>
        </h3>
Was it helpful?

Solution

Try <?php wp_reset_query(); ?> after each function. See Function Reference/wp reset query « WordPress Codex

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top