我明白了!对于将来出现相同问题的任何人:
ACF的get_field_object()
显然,我做了一个WP\\u查询,之后就不会清理了,因为我为每一篇文章都调用了它,所以在精化过程中的某一点之后,我总是得到同一篇文章。我找到了解决办法question.
为清晰起见,一些代码:
<?php while ( $query->have_posts() ) : $query->the_post();?>
<h1><?php the_title();?></h1>
//Some more prints
<?php $field = get_field_object(\'my_field\');
$value = intval($field["value"]);
$label = $field["choices"][$value];
echo $label;
//From this point on every custom field or other data came from the same post
?>
可能有更好的方法来解决这个问题,但它很简单,而且效果很好:
<?php while ( $query->have_posts() ) : $query->the_post();?>
<h1><?php the_title();?></h1>
//Some more prints
<?php
$backup = $post; //Backing up the current post
$field = get_field_object(\'my_field\');
$value = intval($field["value"]);
$label = $field["choices"][$value];
echo $label;
$post = $backup; //Restoring the post
?>