# Count only published posts (in a tag)

**URL:** <https://community.hubspot.com/t/count-only-published-posts-in-a-tag/106993>\
**Category:** CMS Development\
**Created:** [May 13, 2024, 9:39am UTC](https://community.hubspot.com/t/count-only-published-posts-in-a-tag/106993 "2024-05-13T09:39:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SimonPadbury](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/simonpadbury/32/77566_2.png) [@SimonPadbury](https://community.hubspot.com/u/SimonPadbury)\
**Post date:** [May 13, 2024, 9:39am UTC](https://community.hubspot.com/t/count-only-published-posts-in-a-tag/106993/1 "2024-05-13T09:39:12Z")

</div>

I have a blog with a tag “Webinar”, and I wanted to create a feed (template partial) with a panel that shows _only if_ there are some **published** posts tagged “Webinar.” I tried to do this, essentially:

```lia-code-sample
{% set total_webinars = blog_total_post_count('XXXXXXXXXX', 'webinar') %}
{% if total_webinars > 0 %}

<div>
 <h4>Webinars</h4>
 {% set webinars = blog_recent_tag_posts('XXXXXXXXXX', 'webinar') %}

 <!-- for loop ... -->

</div>

{% endif %}

```

However, it’s counting **drafts** tagged “Webinar” too. How do I count only published posts tagged “Webinar”?

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [May 13, 2024, 6:52pm UTC](https://community.hubspot.com/t/count-only-published-posts-in-a-tag/106993/2 "2024-05-13T18:52:45Z")

</div>

Hi, @SimonPadbury 👋 Thanks for the great question. I think the main issue is HubL won’t differentiate between `draft` and published` the way you want it to for this project. Hey @alyssamwilie @miljkovicmisa @Kevin-C, do you have any workaround suggestions for @SimonPadbury?

Thanks! — Jaycee

---

<div class="post-metadata">

**Author:** ![SimonPadbury](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/simonpadbury/32/77566_2.png) [@SimonPadbury](https://community.hubspot.com/u/SimonPadbury)\
**Post date:** [May 15, 2024, 8:58am UTC](https://community.hubspot.com/t/count-only-published-posts-in-a-tag/106993/3 "2024-05-15T08:58:38Z")

</div>

Hey, I’ve figured it out myself.  
_First_, in my original example code, `blog_total_post_count()` wasn’t accepting the parameter ‘webinar’ anyway -- and I should have expected that. `blog_total_post_count()` is simply returning a number, the number of posts (I am surprised that it’s counting drafts too).

Eventually I found `total_count` does what I want, and that leads to this simple solution:

```lia-code-sample
{% set webinars = blog_recent_tag_posts('XXXXXXXXXX', 'webinar') %}
{% if webinars.total_count > 0 %}
<div>
 <h4>Webinars</h4>
 <!-- for loop ... -->
</div>
{% endif %}

```
