Skip Navigation

[Resolved] If view is empty, leave blank instead of “No results found”

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user is getting a div wrapper around his no result found section on the frontend.

Solution:

What you need to do to remove this is to use the custom code below.
https://toolset.com/forums/topic/views-clean-outpoot-for-wpv-no-items-found/#post-539552

Then follow the example that i've provided here
https://toolset.com/forums/topic/if-view-is-empty-leave-blank-instead-of-no-results-found/#post-817673

This support ticket is created 6 years, 8 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.

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

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 6 replies, has 2 voices.

Last updated by rainman 6 years, 8 months ago.

Assisted by: Shane.

Author
Posts
#811111

I have a view like this:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<div class="award-badges tablet-right">
	<wpv-loop>
		[wpv-post-body view_template="Loop item in View for Award Badges"]
	</wpv-loop>
    </div>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
	[/wpv-no-items-found]
[wpv-layout-end]

When no results, is this the correct way to leave output blank?

It does work, but still generates an empty <div id="wpv-view-layout......>. Is there a way to remove that empty div altogether?

#813053

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Thank you for contacting our support forum.

Could you try the solution here and let me know if it helps.
https://toolset.com/forums/topic/views-clean-outpoot-for-wpv-no-items-found/#post-539552

Thanks,
Shane

#813448

No. Since I'm mostly concerned about what happens if there are no results and that part of the view comes after the loop comments, hiding the loop comments does nothing. I still get this empty div.

<div id="wpv-view-layout-798-TCPID485" class="js-wpv-view-layout js-wpv-layout-responsive js-wpv-view-layout-798-TCPID485" data-viewnumber="798-TCPID485" data-pagination="{"id":"798","base_permalink":"/notable-cases/attorney-name/?wpv_view_count=798-TCPID485&wpv_paged=WPV_PAGE_NUM","query":"normal","type":"disabled","effect":"fade","duration":"500","speed":"5","pause_on_hover":"disabled","stop_rollover":"false","cache_pages":"enabled","preload_images":"enabled","preload_pages":"enabled","preload_reach":"1","spinner":"builtin","spinner_image":"<em><u>hidden link</u></em>","callback_next":"","manage_history":"enabled","has_controls_in_form":"disabled","infinite_tolerance":"0","max_pages":0,"page":1,"loop":{"type":"","name":"","data":[],"id":0}}" data-permalink="/notable-cases/attorney-name/?wpv_view_count=798-TCPID485">

	
	
	
</div>
#816045

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

Did you try the function in this exact reply ?

https://toolset.com/forums/topic/views-clean-outpoot-for-wpv-no-items-found/#post-539552

Using the hideit shortcode?

Please let me know.
Thanks,
Shane

#816949

YES

#817673

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hello,

I just tried the solution and it worked for me.

Ensure thats its wrapped around the items that are highlighted below.

[hide-it]
[wpv-layout-start]
[/hide-it]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<ul class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<li>[wpv-post-body view_template="Loop item in Test Hide It"]</li>
		</wpv-loop>
	</ul>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[hide-it]
[wpv-layout-end]
[/hide-it]

Thanks,
Shane

#818614

Okay, I'll try that. In the earlier ticket the [hideit] shortcodes were surrounding the <!-- wpv-loop-start --> comments.