Meta Content Disappearing with Nested Loops (2 posts)

  1. zenhaus
    Posted 5 years ago #


    I have two nested loops inside my main content loop, and the nested loops appear to be preventing my meta content from showing up.

    The nested loops inside my main WP loop are pulling in content from a Custom Post Type.

    Here's my code:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    My second set of meta data (quote and testimonial_author) is not showing up. However, if I remove the first custom post type loop it shows up just fine. I'm guessing there is something wrong with my loop.

    Any ideas on why my nested loop is preventing the additional meta data from appearing on the page?

    Thanks in advance for any insight.

    P.S. I asked this question before but I don't think my post was clear enough. That post can be found here.

  2. vtxyzzy
    Posted 5 years ago #

    I think your secondary loops are stepping on the_post(). Try saving the main post ID and using it in the calls to get_post_custom_values, like this:

    <div class="left">
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
       <?php $main_id = the_ID(); ?>
    <!-- pull in additional Home page meta data in sidebar -->
    	<div id="testimonial">
    	$mykey_values = get_post_custom_values('quote',$main_id);

Topic Closed

This topic has been closed to new replies.

About this Topic