【发布时间】:2021-04-29 16:44:08
【问题描述】:
我在带有画廊 ID 的帖子中有 ACF 自定义字段。自定义字段存储在 wp_postmeta 表中。
我正在尝试在帖子页面上使用分配给此帖子的画廊 ID 执行短代码。
我的代码:
$post = get_post();
$gallery_id = the_field('gallery', $post->ID );
echo do_shortcode('[foogallery id="'. $gallery_id .'"]');
返回“未找到画廊!”
echo($gallery_id); // returns 19557
echo do_shortcode('[foogallery id="19557"]'); // works well
如何使用该帖子的 ACF 值在帖子页面上执行短代码?
我也在尝试 get_field() 但在回显时返回:“数组到字符串转换”
【问题讨论】:
标签: php wordpress advanced-custom-fields foogallery