0

I have two custom post types, "participants" and "reports". Both of them are associated with the custom taxonomy "year".

So in the post "report 1" that is flagged under "2023" taxonomy I want to show the number of "participants" that are flagged under the same taxonomy (2023). The "Report 2" is flagged under "2022" taxonomy and it must show the number of "participants" that are flagged under the same taxonomy (2022). And so on.

Whatever I find online, it's always hard coded. But I need it to be dynamic. Any ideas?

1 Answer 1

0

You have to get them with WP_Query. Creat an array then get the number of posts from found_posts function.

1
  • Hi Mehran. Thanks for your support. Well, I got here: <?php $query = new WP_Query( array( 'category_name' => 'participantes+projetos', 'posts_per_page' => -1 // to retrieve all posts ) ); $count = $query->found_posts; ?> Still, it doesn't seem to be working. Any ideas? Commented May 11, 2023 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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