Count with get_term_by() ONLY the published posts
-
Hello,
I need your help please.
I try to get the number of included posts in different taxonomies. It works fine but at the moment the function returns me the full number of posts and I only wan’t to display the PUBLISHED posts in this taxonomy.
Here is the actual code:
$terms = array(); foreach(explode(',', $cat) as $term_slug) { $terms[] = get_term_by('slug', $term_slug, 'portfolio_category'); } foreach($terms as $term) { $output .= '<a data-value="' . $term->slug . '" href="#">' . $term->name . ' (' . $term->count . ')</a>'; }
Can you guys help me with my problem?
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Count with get_term_by() ONLY the published posts’ is closed to new replies.