我使用了 wordpress 插件 -高级自定义字段,并想显示一个孩子的数组,这是我的代码:
我正在使用此代码显示来自特定页面 ID 子项的自定义字段数据:
<?php $args = array(
'depth' => 0,
'child_of' => 411 );
$pages = get_pages(array('child_of'));
foreach($pages as $post)
{
setup_postdata($post);
$fields = get_fields();
if($fields->company_name != "") : ?>
<h2><?php echo $fields->company_name; ?></h2>
<?php else : ?>
<?php endif; ?>
<?php
}
wp_reset_query();
?>
这是我用来显示页面本身的复选框数据的代码(即它不是父/子):
<?php $catNames = array( 'branding','creative','development','exhibition','packaging','print','seo','social_media','usability','web','advertising','campaign','content','feasibility','publishing','research','strategy');
foreach($catNames as $name){
if(in_array($name, get_field('categories') )){
echo '<a href="/tags/design/'.$name.'" title="'.$name.'">'.ucwords($name).'</a>';
}
}
?>
我想将两者结合在一起,所以在第一个代码框中的 H2 标签下,我想显示孩子的复选框数据,怎么做?
更新:当我将复选框代码添加到子代码时,我无法让数据显示,它要么是空白的,要么有错误。
这是我正在处理的页面。第一个缩略图已被硬编码,第二个和第三个缩略图应该使用上面的代码提取标签,但它没有。