Skip Navigation

[Resolved] Set Conditional display based on number of records returned by View block

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 1.48 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by peterR-3 2 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2267397

When creating a conditional display using the Conditional block, how can I set a condition based on the number of records returned by a View block?

For example, I have a slider created with a View block. When there are 2 or more records/posts returned by the view, pagination dots are displayed below the slider. But when there is only 1 record/post returned, the pagination dots do not display. This causes inconsistent spacing between the slider and the content below depending on whether the pagination dots are displayed or not.

So if the slider View only returns 1 record/post, I'd like to use a Conditional block to display an empty container with similar height to the pagination dots therefore keeping a consistent amount of whitespace.

Thanks

#2267411

Actually, I just wrapped the pagination block in a container with a min-height setting to maintain consistent spacing. So I guess that solves my immediate problem.

Still, for future reference, I'd love to know how to base a condition on the number of records/posts returned by a View block.

Thanks

#2268289

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

You can add a conditional block and select the number of posts returned by view and compare the value. Please check the following screenshot: hidden link

More info:
- https://toolset.com/course-lesson/using-toolset-conditional-block/
- https://toolset.com/2021/08/5-advanced-uses-of-toolsets-conditional-block-in-wordpress/

#2268691

Thanks! Good to know.