Skip Navigation

[Resolved] Using PHP in Views

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

Problem:

The issue here is that the user wanted to know if it was possible to add php functions directly to our Views editor.

Solution:
Unfortunately it's not possible to add raw php to your view editor. What you need to do is to wrap this php code in a shortcode and then use the shortcode in our views plugin.

This support ticket is created 6 years, 1 month 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 2 replies, has 2 voices.

Last updated by nelsonT-2 6 years, 1 month ago.

Assisted by: Shane.

Author
Posts
#613813

Hi,

I have installed a plugin that allows me to add images to categories (or custom posts). The only way to retrieve it (since Views doesn't seem to "see" it) is through PHP
<?php if (function_exists('z_taxonomy_image')) z_taxonomy_image(); ?>

Is it possible to insert PHP in Views (if I try to put some PHP code directly, it transforms it into an html comment)? If not, is it possible to create a custom shortcode (I saw a tutorial on it at some point, don't remember where) and use a shortcode inside Views (I know I've seen that, don't remember where again)...

Nelson

#613884

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Nelson,

Thank you for contacting our support forum.

You are correct as our Views plugin doesn't allow for php to be used directly in the editor. What you need to do is to wrap this php code in a shortcode and then use the shortcode in our views plugin.

Please let me know if this helps.
Thanks,
Shane

#616582

Thank you

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