lundi 9 mai 2016

Wordpress Categories Dropdown Filter show parent and children of specific category

So I am trying to add a filter for specific pages to include a parent category and it's children in the default Categories widget. This is what I have been trying to use but this ends up showing nothing. If I remove the $cat_args['include'] and just use the child_of arg it will just show the children categories from the parent I specify. What do I need to use to show the parent as well as it's children in this filter?

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 );



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire