我正在尝试检索通过高级自定义字段(ACF)创建的字段的值。
目前,我有3个领域小组。但是,当我尝试检索字段的值时,我只能检索字段组之一的值。我无法检索其他2个字段组的值。
我已经尝试过the_field()
,get_post_meta()
,get_field()
,get_field($post->ID)
,get_field('field_name',post_id)
,但都返回NULL或False。
我也尝试过get_fields()
,而这个仅返回字段组之一的数组。
当我尝试var_dump变量以验证是否已检索到值时,这就是我得到的。
https://prnt.sc/ptvjsa(链接到屏幕截图)
<?php
/*
Template Name: Home Page
*/
// Advanced Custom Fields (Product Categories)
$category_section_desc = get_field('our_product_description'); // 1 of the 3 field groups I created
$category_title = get_field('category_title'); // 2nd of the 3 field groups I created
$product_name = get_field('product_name'); // 3rd of the 3 field groups I created
get_header();
var_dump($category_title);
var_dump($product_name);
?>
我的目标是从其他字段组中检索这些字段的值,并将它们全部一起显示在首页中。