Custom taxonomy child not returning post count (1 post)

  1. Tisha Oehmen
    Posted 3 years ago #

    I'm trying to create a custom taxonomy, hierarchical, call "Services". I've been able to get it to recognize and call post count back on parent taxonomies. But it will not recognize counts on child taxonomies. (When I go to the services taxonomies under "Posts" it shows "0" for child taxonomies. However, if I click on the "0", it brings me to a list of posts that shows that there are posts in the taxonomy. -- similarly, get_terms fails to call the child services.)

    I'm sure something's not right with my code, but for the life of me, I can't figure it out. Does anyone have ideas on what I've done wrong? I'd be grateful for your help!

    Here's the code:

    add_action( 'init', 'register_taxonomy_services' );
    function register_taxonomy_services() {
        $labels = array(
            'name' => _x( 'Services', 'services' ),
            'singular_name' => _x( 'Service', 'services' ),
            'search_items' => _x( 'Search Services', 'services' ),
            'popular_items' => _x( 'Popular Services', 'services' ),
            'all_items' => _x( 'All Services', 'services' ),
            'parent_item' => _x( 'Parent Service', 'services' ),
            'parent_item_colon' => _x( 'Parent Service:', 'services' ),
            'edit_item' => _x( 'Edit Service', 'services' ),
            'update_item' => _x( 'Update Service', 'services' ),
            'add_new_item' => _x( 'Add New Service', 'services' ),
            'new_item_name' => _x( 'New Service', 'services' ),
            'separate_items_with_commas' => _x( 'Separate services with comma ', 'services' ),
            'add_or_remove_items' => _x( 'Add or remove services', 'services' ),
            'choose_from_most_used' => _x( 'Choose from the most used services', 'services' ),
            'menu_name' => _x( 'Services', 'services' ),
        $args = array(
            'labels' => $labels,
            'public' => true,
            'show_in_nav_menus' => true,
            'show_ui' => true,
            'show_tagcloud' => true,
            'hierarchical' => true,
            'rewrite' =>  array( 'slug' => 'services' ),
            'query_var' => true
        register_taxonomy( 'services', array('post'), $args );

Topic Closed

This topic has been closed to new replies.

About this Topic