我正在制作一个使用高级自定义字段关系插件的多语言网站。我正在读出雇主,如果我用网站的母语读出它们,我的问题为零,但是当我尝试用另一种语言读出它们时,我得到一个空数组。你们中有人知道我能做什么吗?
<?php
$field = get_post_meta( get_the_id() );
$posts = get_field('field_81');
echo '<!--';
echo 'test ';
var_dump( $field );
var_dump( $posts );
echo '-->';
?>
<?php
if (ICL_LANGUAGE_CODE == 'en'):
?>
<?php
$fields = $field['medewerkers'];
?>
<?php
$posts = $fields;
?>
<?php
endif;
?>
<?php
if ($posts):
?>
<?php
if (ICL_LANGUAGE_CODE == 'nl'):
?>
<h3 class="titelmedewerkers">Medewerkers</h3>
<?php
elseif (ICL_LANGUAGE_CODE == 'en'):
?>
<h3 class="titelmedewerkers">Employees</h3>
<?php
elseif (ICL_LANGUAGE_CODE == 'fr'):
?>
<h3 class="titelmedewerkers">Employes</h3>
<?php
else:
?>
<h3 class="titelmedewerkers">Medewerkers</h3>
<?php
endif;
?>
<ul class="medewerkers">
<?php
foreach ($posts as $post): // variable must be called $post (IMPORTANT)
?>
<?php
setup_postdata($post);
?>
<li class="shadow">
<strong><?php
the_title();
?></strong><br />
<?php
if (get_field('foto')):
?>
<?php
$attachment_id = get_field('foto');
$size = "medium";
$image = wp_get_attachment_image_src($attachment_id, $size);
?>
<img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" /><br />
<?php
endif;
?>
<?php
if (get_field('afdeling')):
?>
<?php
the_field('afdeling');
?><br />
<?php
endif;
?>
<?php
if (get_field('titel')):
?>
<?php
the_field('titel');
?><br />
<?php
endif;
?>
<?php
if (get_field('tel')):
?>
<a href="tel:<?php the_field('tel'); ?>"><?php the_field('tel'); ?></a><br />
<?php
endif;
?>
</li>
<?php
endforeach;
?>
<?php
wp_reset_postdata();
?>
</ul>
<?php
endif;
?>
<?php
wp_reset_postdata();
?>