Wordpress: How to add the OR operator to this query?

I have this piece of code to count the number of posts in a custom taxonomy term and its child terms:

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

                    'child_of' => $id


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


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

The problem is, it returns as a null for the actual term that contains the post, because that has no child terms. I'd like to know if its possible for the query to include the term with the $id and its children as well?

Thank you!


Why not use 'pad_counts' in get_terms.


Need Your Help

When any browser saves a file on android, is there a broadcast sent? How can I intercept saved/downloaded files in a browser on Android?

java android image android-intent

I want to create an application where users can choose to save a file into my application and go through an activity to do so.

UIImage items array of UISegmentedControl does not show images

ios iphone objective-c uiimage uisegmentedcontrol

I want to implement a SegmentedControl Bar with Images, so, I have created an array with UIImages and then I added to the segmented control:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.