Skip Navigation

[Resolved] Views: Execute Shortcode in custom field

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.

This topic contains 5 replies, has 4 voices.

Last updated by Jacob 6 years ago.

Assigned support staff: Luo Yang.

Author
Posts
#34501

Hi,

I would lik to display a a short code i created in Views in a view template.

--> I have a a view I created that can be used to show recent news via a tag: [wpv-views name=Post Listing Shortcode" tag="xxxx"]

--> I created a custom type called recent_news

--> In my Content Template I have the field formatted as I would like it to display:
<div class="news">
<h4 class="title">Recent News</h4>
[types field="recent_news" class="" style=""][/types]
</div>

--> In the admin are I entered in the shortcode in my new custom field. On the fornt-end of the web site it is not parsing the shortcode but rather showing the actual shortcode.

-->I have tried both combination of the following in my functions.php with no luck.

add_filter( 'wpcf-recent_news', 'shortcode_unautop');
add_filter( 'wpcf-recent_news', 'do_shortcode');

AND

add_filter( 'recent_news', 'shortcode_unautop');
add_filter( 'recent_news', 'do_shortcode');

How can I go about adding a shortcode to custom created type and have is parse in a view template? Thank you!

#34572

Luo Yang
Supporter

Languages: English (English ) Chinese (Simplified) (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Dear Sammut,

In order for us to help resolving the problem we need it to be reproduced on a test site.

You are welcome to set a test site using our http://discover-wp.com system. You can set a test site there in few minutes, reproduce the problems and share with us the access details so we will be able to review it.

Here is a description for why and how to do this:
https://toolset.com/faq/how-and-why-to-create-a-test-site-in-discover-wp/

Thank you
Luo

#34763

OK I changed my approach that perhaps will alleviate the need for me to setup a test site.

I would like to execute this short code within my view template using a variable. Can you let me know how to accomplish this:

[wpv-view name="Post Listing Shortcode" tag="[types field='recent_news' class='' style=''][/types]"]

#34764

Never mind, go it!

#131808

Gah! Share your solutions!!

#244693

Helpful.