Skip Navigation

[Resolved] Conditional Not Working Correctly On View in Block Editor

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

Problem:
The user has created a grid view and enounters an empty cell on the frontend.

Solution:
The user was using a condition inside the view loop to show/hide the post. The grid is built for each post on the loop, so, even if the post is not shown, its grid cell is already created.

The user should use a query filter to pull only the post he needs to display.

This support ticket is created 3 years, 9 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 – 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: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Kirk 3 years, 9 months ago.

Assisted by: Jamal.

Author
Posts
#1714631
toolset-blocks-view-front-end-200722.jpg
block-editor-inverter-200722.jpg

Hi,

We have created a View with a conditional and it seems to be displaying all of the custom posts in the block editor in wp-admin instead of only those specified by the conditional.

When displaying on the front end of the website it does NOT display the incorrect custom post BUT it does leave a blank block where the incorrect post might be displayed.

See this page; hidden link

Toolset Blocks Version is 1.2.1, Toolset Types is 3.3.12 and WordPress is 5.4.2

Thanks in advance for any help you can offer.

Kirk

#1714915

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello Kirk and thank you for contacting the Toolset support.

This seems to be a cache related issue, please check if this issue appears when:
- Only Toolset plugins are activated. It will tell us if there is an interaction issue with another plugin.
- The theme is set to a WordPress default like Twenty Fourteen. It will tell us if there is an interaction issue with your theme.
If the problem disappears, start activating one at the time to track where the incompatibility is produced.

If this does not help, I would like to check the conditions on your view's loop. I'll try to reproduce it locally to verify if it is a bug or just an exception that happens on your site/server. If you would allow me temporary access to your admin area, your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1716113

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello Kirk and thank you for the credentials.

It is expected that you have an empty grid cell. Because the conditional is already inside the loop. Even if what is inside the conditional is not displayed, the wrapper element of the current post in the loop will be displayed, and anything else inside the loop that is outside of the conditional.

If I understand well your conditional block, you would like to display only the posts where the product type equals "Inverter", right?
In that case, you will need to add this to the view's query filter. That way, only posts that match the conditions will be returned by the view loop and you won't need to use the conditional block.
The conditional block inside the loop will be useful if you want to customize the output per post(post data), for example displaying a different string or image depending on a condition on the post.

Check this screencast where I added the query filter on the product type hidden link

And check the results here hidden link

If this is what you are looking for, you may remove the conditional block as it is not useful anymore and may cause some additional processing time for the page.
If that's not what you would like to have, please elaborate more on what you expect to have?

#1716749

Thanks so much Jamal.

I can see what you have done fixes my issue but I just seem to get caught up before you start your video.

I have had a quick go at it now but I seem to get stuck before the bit where you show me how to complete the setup.

I can't spend time on this today but if there is a link to a full tutorial video on how to construct a view with a query in your documentation then I would appreciate a link to it.

If not I will proceed to work through it again early next week (I am in Western Australia so it is now Friday morning here).

Given sufficient trial and error I am sure I will get it.

Thanks so much for your help and your patience.

best regards
Kirk

#1717073

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello Kirk and thank you for your kind feedback.

Check this Youtube playlist on how to use Toolset in the new Gutenberg Editor hidden link
The first video is produced by Nigel who also provides support here in the forum. Feel free to ask any questions about it here in the forum or if the chat is open.

All the best! Thanks

#1720405

My issue is resolved now. Thank you!

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