Can someone tell me why the meta keys aren't displayed when i use this shortcode?
function produktinformation() {
global $post;
setup_postdata($post);
$brennwert1 = get_post_meta($post->ID, 'Brennwert (pro 100g)', true);
$brennwert2 = get_post_meta($post->ID, 'Brennwert (pro Portion)', true);
$eiweiß1 = get_post_meta($post->ID, 'Eiweiß (pro 100g)', true);
$eiweiß2 = get_post_meta($post->ID, 'Eiweiß (pro Portion)', true);
$kohlenhydrate1 = get_post_meta($post->ID, 'Kohlenhydrate (pro 100g)', true);
$kohlenhydrate2 = get_post_meta($post->ID, 'Kohlenhydrate (pro Portion)', true);
$zucker1 = get_post_meta($post->ID, 'Zucker (pro 100g)', true);
$zucker2 = get_post_meta($post->ID, 'Zucker (pro Portion)', true);
$fett1 = get_post_meta($post->ID, 'Fett (pro 100g)', true);
$fett2 = get_post_meta($post->ID, 'Fett (pro Portion)', true);
$fettsaeuren1 = get_post_meta($post->ID, 'gesätt. Fettsäuren (pro 100g)', true);
$fettsaeuren2 = get_post_meta($post->ID, 'gesätt. Fettsäuren (pro Portion)', true);
$ballaststoffe1 = get_post_meta($post->ID, 'Ballaststoffe (pro 100g)', true);
$ballaststoffe2 = get_post_meta($post->ID, 'Ballaststoffe (pro Portion)', true);
$natrium1 = get_post_meta($post->ID, 'Natrium (pro 100g)', true);
$natrium2 = get_post_meta($post->ID, 'Natrium (pro Portion)', true);
return '
<div class="produktinfo_ungerade produktinfo_kopf">bei Zubereitung lt. Anleitung</div>
<div class="produktinfo_ungerade produktinfo_ueberschrifteins">Nährwerte</div>
<div class="produktinfo_ungerade produktinfo_ueberschriftzwei">pro 100g</div>
<div class="produktinfo_ungerade produktinfo_ueberschriftdrei">pro Portion</div>
<div class="produktinfo_spalteeins_hoch">Brennwert</div>
<div class="produktinfo_spaltezwei_hoch">' . $brennwert1 .'</div>
<div class="produktinfo_spaltedrei_hoch">' . $brennwert2 . '</div>
<div class="produktinfo_ungerade produktinfo_spalteeins">Eiweiß</div>
<div class="produktinfo_ungerade produktinfo_spaltezwei">' . $eiweiß1 . '</div>
<div class="produktinfo_ungerade produktinfo_spaltedrei">' . $eiweiß2 . '</div>
<div class="produktinfo_spalteeins">Kohlenhydrate</div>
<div class="produktinfo_spaltezwei">' . $kohlenhydrate1 . '</div>
<div class="produktinfo_spaltedrei">' . $kohlenhydrate2 . '</div>
<div class="produktinfo_ungerade produktinfo_spalteeins">- Zucker</div>
<div class="produktinfo_ungerade produktinfo_spaltezwei">' . $zucker1 . '</div>
<div class="produktinfo_ungerade produktinfo_spaltedrei">' . $zucker2 . '</div>
<div class="produktinfo_spalteeins">Fett</div>
<div class="produktinfo_spaltezwei">' . $fett1 . '</div>
<div class="produktinfo_spaltedrei">' . $fett2 . '</div>
<div class="produktinfo_ungerade produktinfo_spalteeins_hoch">gesätt. Fettsäuren</div>
<div class="produktinfo_ungerade produktinfo_spaltezwei_hoch">' . $fettsaeuren1 . '</div>
<div class="produktinfo_ungerade produktinfo_spaltedrei_hoch">' . $fettsaeuren2 . '</div>
<div class="produktinfo_spalteeins">Ballaststoffe</div>
<div class="produktinfo_spaltezwei">' . $ballaststoffe1 . '</div>
<div class="produktinfo_spaltedrei">' . $ballaststoffe2 . '</div>
<div class="produktinfo_ungerade produktinfo_rundeins">Natrium</div>
<div class="produktinfo_ungerade produktinfo_spaltezwei">' . $natrium1 . '</div>
<div class="produktinfo_ungerade produktinfo_rundzwei">' . $natrium2 . '</div>'
;}
add_shortcode('produktinfo', 'produktinformation');
It's working when I put this code in the page loop.