Support

Account

Home Forums Add-ons Repeater Field Querying database for repeat sub fields displaying revisions Reply To: Querying database for repeat sub fields displaying revisions

  • Thanks Elliot.

    I ended up wrapping the contents of the foreach with a conditional, and it seems to have done the trick.

    foreach( $rows as $row )
    	{
    	if ( get_post_status($row->post_id) == 'publish' ) :	
    		preg_match('_([0-9]+)_', $row->meta_key, $matches);
    		$name_key = 'awards_' . $matches[0] . '_award-name'; // $matches[0] contains the row number
    		$year_key = 'awards_' . $matches[0] . '_award-year';
    
    		$award_name = get_post_meta( $row->post_id, $name_key, true );
    		$award_year = get_post_meta( $row->post_id, $year_key, true );
    		echo '<li><span class="award-name">'. $award_name .'</span>, <span class="award-yeaer">'.$award_year.'</span></li>';
    	endif;
    	}