Skip Navigation

[Resolved] Fields and Views – Modify Shortcode Output

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

Problem:

We are needing a way to extend/modify the existing field and view shortcodes.

Solution:

Toolset View/Types shortcodes are also registered with WP function add_shortcode(), so you can use WP built-in filter hook do_shortcode_tag to apply your custom codes

Relevant Documentation:

https://developer.wordpress.org/reference/hooks/do_shortcode_tag/

This support ticket is created 3 years, 8 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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by Team DNK 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1694507

Hey Support,

We are needing a way to extend/modify the existing field and view shortcodes. For example, I would like to modify [wpv-post-link] so that it automatically wraps each list item within this shortcode with a <span> tag that has a specific name attribute as well as data attribute. The reason we need this is so we can have special behavior on our views using Javascript. I am aware that I am able to use html view and manually build out the markup so that it looks something like:

<span name='custom-name' data-id=[wpv-post-id]>[wpv-post-link]</span>

But we will be using this very often and need this type of structure to be applied to every instance of the shortcode. We will also be needing to do similar behavior on other field and view shortcodes. How can we go about accomplishing this?

Thanks,
Bernard

#1697687

Hello,

Toolset View/Types shortcodes are also registered with WP function add_shortcode(), so you can use WP built-in filter hook do_shortcode_tag to apply your custom codes, see WP document:
https://developer.wordpress.org/reference/hooks/do_shortcode_tag/
Filters the output created by a shortcode callback.

#1702967

Thanks for the response. I did attempt to use do_shortcode_tag original but I could not retrieve the post.

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