Wordpress类别下拉过滤器显示特定类别的父级和子级

时间:2016-05-09 23:12:15

标签: wordpress wordpress-plugin wordpress-theming

因此,我尝试为特定页面添加过滤器,以在默认的“类别”窗口小部件中包含父类别及其子项。这是我一直试图使用但最终没有显示任何内容。如果我删除$ cat_args [' include']并只使用child_of arg,它将只显示我指定的父类别中的子类别。在此过滤器中,我需要使用什么来显示父母及其子女?

function widget_categories_args_filter( $cat_args ) {
    if (is_page('83335')) {
        $cat_args['hide_empty'] = 0;
        $cat_args['include'] = 197;
        $cat_args['child_of'] = 197;
    }else{
        $include_cats = array();        
    }

    return $cat_args;
}

add_filter( 'widget_categories_dropdown_args', 'widget_categories_args_filter', 10, 1 );

0 个答案:

没有答案