Hey guys!
I've got the same issue I had a few months ago. I'm not sure we ever really fixed it.
Querying if a group is empty or not doesn't seem to work as described in the docs.
The code I'm using:
// Coverage Shortcode
function epi_publication_coverage_shortcode() {
ob_start();
// Press Coverage
$coveragegroup = rwmb_meta( 'epi_pubcoverage' );
if ( ! empty( $coveragegroup ) ) {
echo 'NOT EMPTY';
}
else {
}
return ob_get_clean();
}
add_shortcode('show_publication_coverage','epi_publication_coverage_shortcode');
Displays "NOT EMPTY" on all posts, even if they don't have any coverage.
Is the group saving a blank field somewhere? Should I be querying on a checkbox or something instead?
Code used to register group:
// Add Coverage Meta Boxes
$meta_boxes[] = array(
'title' => 'Press Coverage',
'post_types' => array('post', 'report', 'analysis', 'guest-blog'),
'context' => 'normal',
'priority' => 'low',
'desc' => '(drag to reorder)',
'fields' => array(
array(
'id' => 'epi_pubcoverage',
'type' => 'group',
'clone' => true,
'sort_clone' => true,
'fields' => array(
array(
'name' => 'Title',
'id' => $prefix . 'pubcoveragedesc',
'type' => 'text',
'desc' => 'Title or description for link',
),
array(
'name' => 'URL',
'id' => $prefix . 'pubcoverageurl',
'type' => 'text',
'desc' => 'Link to coverage',
),
array(
'name' => 'Date',
'id' => $prefix . 'pubcoveragedate',
'type' => 'date',
'desc' => 'Date of event coverage',
),
),
),
),
);
return $meta_boxes;
And all plugins have been updated to latest versions.