Term Count as a condition

Hi,

I would like to hide an element and show another if there was 1 post using a particular term within a group of posts for a custom post type.

I can’t seem to get it working. Can you suggest how you would do this please?

THanks,
Darren.

Hello Darren,

Thanks for writing in! You can only get a Term count if you enclose your element inside a Looper Provider All Terms or Looper Provider Current Terms to get the term count. The number condition with dynamic content {{dc:looper:index}} > 1 or {{dc:looper:index}} <= 1 can be used in your element to show or hide it.

Hope this makes sense.

Hey Reunel,

Thanks for the clarification. I’ve set up the Provider Current Terms in the Row set to the custom taxonomy with Consumer set to All.

Where do I add the condition so that the Index only returns the count on a particular term? I assume that {{dc:looper:index}} will give me a count on all posts with any term from that custom taxonomy, right?

thanks.
Darren.

WHere

Hello Darren,

Could you please send me the URL of the page that you are currently working on? I just want to check your element structure and get a clear idea of how you may be able to use the condition on the page. Normally, the items should be inside your looper so that you can use the condition.

Thanks.

Hey Ruenel,

https://boomfitfootball.com.au/members/

I will add login to test account in the secure Note section.

Thanks,
Darren.

Hey Darren,

The given credentials do not have an administrative role. We cannot check your WP dashboard. Please change the role to Administrator instead.

Best Regards.

Hi Ruenel,

Those credentials were so you could login as that subscriber and get to the URL you wanted to check the Element Structure. I’'ve updated that subscriber to Admin now so you can also get into Cornerstone.

Sorry,
Darren.

Hi Darren,

You can use the {{dc:looper:count}} inside the Looper to get the total item count.

Thanks

Hi Tristup,

I am having trouble getting the count of the number of posts returned by the Provider. It just gives me the total number of custom posts. This is the looper setup I am using:

ROW: Looper Provider: Query Builder - set to pull specific post type with specific Taxonomy
With condition: email field in post matches User Email
Looper Consumer set to ALL

Element Condition: {{dc:looper:count}} == 0

Also I dont know how to show the element when the count is 0 - because there are no posts, it doesnt show the element using the condition.

THanks,
Darren.

Hey Darren,

The {{dc:looper:count}} inside the looper should do the trick but upon checking your member page, I am unsure which column you are working with. Would you mind pointing us to the right one?

Thank you.

Hey Marc,

The element I’m trying to show is “Waiver Button” and its in the “Docs to Sign” row. I would like it to show if there are no “Signed Document” Custom posts that have the term “Signed Waiver” where the User Email matches the field “signed_parent_email”.

thanks,
Darren.

Hey Darren,

I am seeing this:

You have a Looper Consumer but no Looper Provider. Can you please provide a data structure so that we can understand how the Signed Document relates to the Signed Waiver?

Thank you in advance.

Hi Ruenel,

The Consumer you are pointing out is for the Looper Provider in the row (Docs to Sign).

The data structure is:
Custom Post: Document has the taxonomy Signed Document

Signed Document taxonomy has the terms: Signed Waiver, Signed Questionnaire

I am wanting to show the element “Waiver Button” only if there are no Document Posts with the term Signed Waiver that also match the condition: signed_parent_email is User Email.

I am wanting to show the element “Waiver Signed” if there is a Document Post with the term Signed Waiver that also matches the condition: signed_parent_email is User Email.

Hope that is clear.

Thanks,
Darren.

Hey Ruenel,

I have worked it out, thank you for your guidance - much appreciated.

Cheers,
Darren

You are most welcome, Darren.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.