0

カスタム分類用語とその子用語の投稿数をカウントするための次のコードがあります。

    function wp_get_postcount($id)
            {
            $count = 0;
            $taxonomy = 'productcategories';
            $args = array(

                    'child_of' => $id

            );



            $tax_terms = get_terms($taxonomy,$args);

            var_dump($tax_terms);

            foreach ($tax_terms as $tax_term) {
            $count +=$tax_term->count;
            }
            return $count;
            }   

問題は、子用語がないため、投稿を含む実際の用語に対してnullとして返されることです。クエリに$idとその子を含む用語を含めることが可能かどうか知りたいですか?

ありがとうございました!

4

1 に答える 1