[Resolved] empty items created in a post loop

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.

This topic contains 1 reply, has 2 voices.

Last updated by Beda 8 months, 2 weeks ago.

Assigned support staff: 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.