【发布时间】:2017-12-12 00:22:06
【问题描述】:
我在专用 php 模板(无 Pods 模板)中的 Wordpress 循环中回显来自自定义帖子类型(使用 Pods 创建)的所有自定义字段值。这适用于所有自定义字段,relationship / simple / multiple selection list 字段除外。仅回显/返回多个选定值中的第一个。
我在 php 模板中使用了这段代码:
while ( have_posts() ) : the_post();
$title = get_the_title();
$image = get_the_post_thumbnail();
$location = get_post_meta(get_the_id(), 'location', true);
$types = get_post_meta(get_the_id(), 'types', true);
etc.
稍后我会重复所有这些价值观。我有问题的字段是types:
当我回显$types 时,仅回显/返回该字段的第一个选定值。我认为它可能是一个数组,并尝试print_r($types) 进行检查,但这也只显示一个(第一个选择的)键/值对,没有数组。
字段选择类型为multiple-select,格式为checkboxes(如果有任何相关性)。
我可以做些什么来获取和显示该字段的所有选定值?
【问题讨论】:
标签: php wordpress custom-post-type podscms