Skip Navigation

[Resolved] Shortcode and PHP

This support ticket is created 4 years, 4 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: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 4 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#1402067

Hello,

I tried to put this code in a header.php file but it does not work.

<?php
echo do_shortcode( '[wpv-conditional if="(\'[types usermeta=\'votre-sport\' current_user=\'true\' output=\'raw\'][/types]\' eq \'basket\')"]<p>texte</p>[/wpv-conditional]' );
?>

Why ?

Thanks

#1402469

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Christophe,

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

A better way to include these shortcodes in the header.php file would be through a content template:

1. You can create a new content template from Toolset -> Content Templates and insert your desired shortcodes, in that.
( it doesn't need to be assigned to any page, post type or archive etc )

Example:


[wpv-conditional if="( '[types usermeta='votre-sport' current_user='true' output='raw'][/types]' eq 'basket' )"]
<p>texte</p>
[/wpv-conditional]

2. After that, you can echo this content template's output in the header.php file, using the content template shortcode (wpv-post-body):
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body )


echo do_shortcode('[wpv-post-body view_template="template-slug" suppress_filters="true"]');

Note: You'll replace "template-slug" with the actual slug of your content template.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

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