【问题标题】:Wordpress - Query categories list with advanced custom field argumentWordpress - 使用高级自定义字段参数查询类别列表
【发布时间】:2013-06-19 19:36:10
【问题描述】:

我使用高级自定义字段插件,该插件非常适合向帖子或类别添加其他字段,但我找不到向 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>';
}
}

非常感谢您的帮助!

【问题讨论】:

    标签: php wordpress


    【解决方案1】:
        $value = get_field('ligue');
    

    你没有把参数$category->cat_ID

    查看http://www.advancedcustomfields.com/resources/functions/get_field/了解更多信息。

    应该是这样的:

        $value = get_field('ligue', $category->cat_ID);
    

    【讨论】:

      猜你喜欢
      • 2018-02-04
      • 2017-08-28
      • 2015-07-31
      • 1970-01-01
      • 2013-11-25
      • 2015-02-16
      • 2021-04-30
      • 2023-03-17
      • 2015-09-01
      相关资源
      最近更新 更多