0

How do I only display individual fields in the ACF Address add on. For example I have three address lines but only want one to be output:

Address Line 1: Curtis Mayfield House
City: Newcastle Upon Tyne
Country: United Kingdom

And I just want to display Address Line 1: Curtis Mayfield House.

Any help would be much appreciated

4

1 回答 1

0

您可以使用 get_post_meta 来做到这一点。以下内容为您提供每个字段的数组:

$address = get_post_meta(get_the_id(), 'your_acf_field', true);

然后你可以使用:

echo  $address['city']

这显然需要在您的 wordpress 循环中。如果您想在循环之外使用它,只需输入帖子 ID 作为第一个参数:

$address = get_post_meta(76, 'your_acf_field', true);

其中“76”是您帖子的 ID。希望这可以帮助。

于 2012-10-30T10:24:26.083 回答