Hi there - I'm starting a new thread since other was marked as solved without detailing how.
I need to add a shortcode to a CPT in the backend using a custom field that will then show on the front end. Is this possible?
Thank you for reaching out.
Please follow this documentation to know how to use the shortcode
[ rwmb_meta ]
Hi Long - thanks for your quick response.
Let me clarify - I don't want to create a shortcode of the Meta Box custom field, I need to add an existing shortcode from another plugin (in this case to show a registration form on the front end).
Here's my workflow:
Create CPT > Add custom field for shortcode > copy/paste registration form shortcode into custom field > registration form is visible on the front end.
If it matters, I'll be using Elementor to pull the custom fields to a template for the CPT.
Maybe there is a function I can add to my theme file to let me add shortcodes to the custom HTML field?
Thank you for your additional information.
If you want to insert a shortcode from another plugin, you can just use the widget Shortcode of Elementor to insert it, no need to insert via a custom field.
Or you can insert a shortcode via the field type WYSIWYG https://docs.metabox.io/fields/wysiwyg/
I inserted in WYSIWYG-Field a shortcode from Plugin "Content Blocks (Custom Post Widget)".
But if i use rwmb_meta("acf-single-prod-summary-prolog") it outputs only the string of shortcode like this: [content_block slug=s-prod-summary-prolog-3dportrait]
I came from "acf", it had always worked there.
Hope there is a solution.
Thank you in advance
I've now noticed that there is a need to run an extra line of code.
echo do_shortcode( wpautop( $value ) )
I work with Oxygenbuilder's repeater element.
I have no way of executing this code in it.
Is there a way i can basically define the output as rendered, or do you have another idea?
Thank you in advance
Hey there, is there any solution to this?
I have also migrated from ACF to MB and I can as well confirm that in ACF shortcodes as values were generated properly on front end. Now with Metabox, using similar settings, shortcode is generated as text on front end.
[oxygen-template id="746"]: Label 1 [oxygen-template id="795"]: Label 2
I switched back to ACF temporarily until there is an solution.
As you can see the support is bad here.
Astwert, if it helps in any way, for one of my simple use cases (not in repeater) I'm applying a workaround to put all possible shortcodes inside oxy template and make use of MetabBox fields for display conditions. It's a pain but it works.
@MetaBox, any guidance (or better yet a properly integrated solution to this) would be highly appreciated.
As you can read on the documentation, the helper shortcode
[rwmb_meta] supports rendering the inner shortcode inside the field value. You need to set the attribute
Yup, '[rwmb_meta id="seo_text" render_shortcode="true" raw="true"]' renders TablePress shortcodes for example.
Well, part of the solution can also be found in https://support.metabox.io/topic/output-shortcode-from-a-custom-field/.
I can however, with posts in this thread and in the before mentioned thread, got it to work as expected.
I have the same problem and the rendering option does not work.
I have a custom field that contains a shortcode but it does not render the shortcode. Can you fix this?
I have tried all possible fields.
With ACF it is easier, it can render the shortcode correctly but MB cannot.
My process is as follows:
I create a custom field for post type "post" with name shortcode. When I customize a template with Oxygen Builder, I include the custom field.
When viewing an example it only displays the shortcode as follows [shortcode] in text format without being able to render it.