Skip Navigation

[Resolved] empty items created in a post loop

This support ticket is created 4 years, 6 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 1 reply, has 2 voices.

Last updated by Beda 4 years, 6 months ago.

Assisted by: Beda.

Author
Posts
#1370219

we created a page that holds a view of a series of post contents but from time to time it creates some "empty"

<li>

items without any reason.
you can see the page at the following url:

hidden link

if you see some images are not aligned because there are some empty

<li>

items that create spage

#1370535

This should be because there is nothing to display for that item in the list
I assume you have a ShortCode in that list, and that ShortCode displays the contents of a field, but that field is not filled out for each and ever post in the loop.

You can use HTML conditionals to resolve this:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
You will be wrapping the entire

<li>[shortcode]</li>

into a HTML condition to check if the [shortcode] is empty or not, and only show it if it's not empty.

Another approach can be to orderby that precise field the View, which will automatically exclude all the posts that have no such field.
But usually the HTML conditional solution is neater.

Please let me know if you need more details about this.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.