Problem: I have added some shortcodes inside a WYSIWYG custom field. I would like to output the results using get_post_meta, but the shortcodes are not executed. They are just written out in the content of the field.
Solution: The WordPress function get_post_meta retrieves raw data from the database, but does not execute any shortcodes in that content. So the behavior you're experiencing is expected, if not what you're trying to accomplish. Take a look at the WordPress API "do_shortcode()".
$field = get_post_meta(get_the_ID(), 'wpcf-extra-text-under-products', true); echo do_shortcode($field);
Or you can try applying filters to that field value like so:
echo apply_filters('the_content', get_post_meta(get_the_ID(), 'wpcf-extra-text-under-products', true));
Relevant Documentation: https://developer.wordpress.org/reference/functions/do_shortcode/
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 |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 3 replies, has 2 voices.
Last updated by 6 years, 9 months ago.
Assisted by: Christian Cox.