Shortcodes should never echo
; they should always return
the text to be displayed. See the User Contributed Notes in the add_shortcode()
docs.
Your code should read more like this:
function displayTable() {
$string = '';
$string .= '<table>';
$string .= '<tbody>';
$fields = get_field_objects();
foreach($fields as $field)
{
$string .= '<td>';
$string .= '<td>'. $field['label'] .'</td>';
$string .= '<td>'. $field['value'] .'</td>';
$string .= '</tr>';
}
$string .= '</tbody>';
$string .= '</table>';
return $string;
}
add_shortcode('popnagel-tabel', 'displayTable');