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;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.