我使用高级自定义字段插件,它可以为帖子或类别添加额外的字段,但我找不到一个解决方案来为get_categories函数添加参数。
我想显示一个类别列表,其中child_of=X和一个特定的自定义字段必须等于Y但我的代码显示所有的子…
foreach(get_categories('child_of=4') as $category) {
// Get the icon in a variable
$my_icon = get_cat_icon('echo=false&cat='.$category->cat_ID);
// Display a list with icons and the category names
$value = get_field('ligue');
// Get value of ligue
if ($value == 1) {
echo '<div class="contentmenupage"><a href="'.get_category_link($category->cat_ID).'">'.$my_icon.'</a><br> <a href="'.get_category_link($category->cat_ID).'" title="'.$category->description.'">'.$category->cat_name.'</a><p>'.get_field('fondation', 'category_' . $category->cat_ID ).'<br>'.get_field('stade', 'category_' . $category->cat_ID ).'<br>'.get_field('couleurs', 'category_' . $category->cat_ID ).'<p></div>';
}
}
非常感谢你的帮助!
$value = get_field('ligue');
您没有输入参数$category->cat_ID
查看http://www.advancedcustomfields.com/resources/functions/get_field/获取更多信息。
应该是这样的:
$value = get_field('ligue', $category->cat_ID);