Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How I can get sub category in WordPress in a short-code

I would like to show subcategory list in a short code.
I like if shortcode will be like [football_subcategory]

I want all list all sub category in a list

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can get it like this:

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);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading