Skip Navigation

[Resolved] don't show headline of view if no-items-found with block editor view

This support ticket is created 3 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by TorstenR3514 3 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1912547

I am trying to don't display the headline of the view (not in the loop) if the loop has no-items-found.

I have created a single post template with two nearly identical related post views under the post-content, which are filtered by taxonony category of the single post.
The first view is created with the block editor the second with the legacy editor.

hidden link
has related posts by taxonomy category

hidden link
has no related posts by taxonomy category

The headlines of the view shouldn't appear.
It works fine with the legacy editor by placing the headline behind [wpv-items-found] and an empty [wpv-no-items-found] tag.
But it looks like I can't do this with the block editor? right?

It would be awesome if there would be an option to display any code if the view has no items. By conditional field or functionality of the view itself. Still hoping. Otherwise it looks like I a have to rebuild my views with the classic editor.

#1912903
conditional-block-condition.png
conditional-block-placement.png
No-Items-Found-Text.png

Hi,

Thank you for contacting us and I'd be happy to assist.

I can think of two approaches that you can use for this:

1. To include some generic custom CSS code, only when the blocks based view returns no items, you can use the "No Items Found Text" field in the "View Loop" block.
( screenshot: No-Items-Found-Text.png )

Example CSS code:


<style>
body {background: red;}
</style>

2. Alternatively, you can move your heading inside the conditional block, which is placed at the same level as the "View Loop" block, but not inside it.
( screenshot: conditional-block-placement.png )

In the condition settings, you'll set it to show only when number of items found, is greater than or equal to '1'.
( screenshot: conditional-block-condition.png )

regards,
Waqar

#1913129

The Conditional block "Number of items found in Views is greater than or equal to 1." with the heading placed inside made it.

Missed to check the Conditional setting for "Views Shortcodes". That will help a lot in the feature!

Thank You Wakar!

Update: I think I wrongly chose "very difficult" instead of "very easy". Of course it was very easy;)