如何在WordPress的短代码子类别

jxct1oxe  于 2022-11-22  发布在  WordPress
关注(0)|答案(1)|浏览(106)

我想在一个简短的代码显示子类别列表。我喜欢如果短代码将像[足球_子类别]
我要全部列出所有子类别

g6baxovj

g6baxovj1#

你可以这样得到它:

add_shortcode('football_subcategory', 'football_subcategory');
function football_subcategory(){
    $taxonomies = array( 
    'event_cat',
);

$args = array(
    'parent'         =>1625, //put your parent category ID
    'hide_empty' => false, // you can make it true and false
    // 'child_of'      => $parent_term_id, 
); 

$terms = get_terms($taxonomies, $args);
//add a loop and get all details about category
    echo '<pre>';
    print_r($terms);
}

相关问题