Skip Navigation

[Resolved] How can I display post fields/post metas conditionally inside a post?

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: Asia/Karachi (GMT+05:00)

Author
Posts
#2628713

Tell us what you are trying to do?
I was trying to use the wpv–conditional shortcode inside a post. But apparently that is only possible inside a view, template or archive. Is there a way to display post fields/post metas conditionally inside a post?
Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2628963

Hi,

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

The Toolset conditional shortcode 'wpv–conditional' should work from the post's content/body too, without any content template or view.

Here is a link to the documentation on the topic:
https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/

In case, it is not working, please share the exact steps and the details and I'll be in a better position to troubleshoot this.

regards,
Waqar

#2628987

Hi Waqar, thanks for your reply. I can confirm that it works in the post's content. Now we tried to use it inside a custom layout hook with astra theme (hidden link). This astra custom layout hook can then dynamically be inserted in the desired post's content (which is a really nice feature of the astra theme). Unfortunately that doesn't work in conjunction with the wpv-conditional tag. It seems the wpv-conditional shortcode fires too early. That's why the wpv-conditional tries to check the astra custom layout hook instead of the post where the custom layout hook is inserted. Other shortcodes like [wpv-post-title] do work inside astra custom layout hooks. Do you have any idea how to get to work the [wpv-conditional] too?

#2629927

Thanks for writing back.

I don't have much experience with the 'custom layout hook' feature from Astra, but their documentation mentions that the execution priority can be adjusted:
hidden link

Can you test by increasing the priority number, to further delay the execution?

Another alternate that you can try is to add conditional statements inside a Toolset content template and then load that template in the custom layout hook, through the 'wpv-post-body' shortcode:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body

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