Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Here is what I have:

A custom post type that has a custom meta value added to a post that stores the posts expiry date. When the post passes this expiry date it no longer shows on the site.

This works but I'm using something like this to list the terms for the custom post type:

$termcats = get_terms('dcategory', 'hide_empty=0&orderby=name&pad_counts=1');

I'm showing the count of posts in the listed terms but the problem here is that the count shows all post whether or not if the post has expired. So for example I have one post in the term called test and that post is expired. The above code shows there is one post but when the user click the category they get a blank list.

So I need a way to hook into get_terms() to ignore posts that have expired according to my date field in meta values.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

As far as I remember counts for terms are stored in database, so there is nothing to modify when you fetch them - you simply get ready-made numbers.

So you will either need to implement and maintain your special logic for counts completely separately or try to recalculate and modify native counts, see wp_update_term_count_now().

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.