doudi8829 2011-02-03 21:26
浏览 33
已采纳

WordPress循环中的非关闭PHP查询

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>
  • 写回答

1条回答 默认 最新

  • dongmangsha7354 2011-02-03 21:42
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?