Support Forum
Hello.
I have a custom field set up where a unique shortcode would be entered for each post. What I've tried so far will not output the rendering of the shortcode. Instead, on the frontend, the text of the unique shortcode for that post is visible. I'm using Oxygen Builder.
How it is set up:
- I have a custom field with the ID of checkout-form-shortcode. This field group is applied to the Products post type.
- In the template assigned to Products, I have a shortcode element with the following shortcode [rwmb_meta id="checkout-form-shortcode"]
- On the frontend, the text of the shortcode that was entered in that custom field for the specific post is displayed.
Can you possibly point to where I may be doing this incorrectly? I was using ACF before purchasing Meta Box, and was able to make this work using php.
Thank you!
Hi,
Thank you for reaching out.
Currently, the helper shortcode [rwmb_meta]
does not support render shortcodes in the field value. If you use the field type WYSIWYG, please run it via PHP code. Get more details on this documentation https://docs.metabox.io/fields/wysiwyg/#template-usage
Can you please tell me how to make this work?
Would I put this in a code block element? If so, would I replace the custom field ID with the one I've created?
$value = rwmb_meta( $field_id );
echo do_shortcode( wpautop( $value ) );
I need some more support to get this to work. Thanks.
Hi,
You need to wrap the code in a function, just like
function my_custom_function() {
$value = rwmb_meta( 'checkout-form-shortcode' );
echo do_shortcode( wpautop( $value ) );
}
apply the function with the plugin Code Snippets or code block as you want. Then show the field value with PHP Function Return Value.
Thank you for your reply.
I am getting the return of 'function does not exist'.
I have this code snippet created: https://moveyourfamilyabroad.com/wp-content/uploads/2021/05/Screenshot-2021-05-02-104348.png
I used the PHP Function Return Value. I am unclear what is entered in the argument line. I've tried entering various values with all the same result: https://moveyourfamilyabroad.com/wp-content/uploads/2021/05/Screenshot-2021-05-02-104431.png
Can you tell me please if I'm entering the wrong info into the Php return value option or where else I may be going wrong? Thanks!
Hi,
Did you enable the snippet? Screenshot https://share.getcloudapp.com/d5u12RZG
There are no arguments need to pass to the custom function so you can remove it.
[oxygen data='phpfunction' function='my_custom_function']
Ahh - yes, that detail was missed on my end. Thank you so much! It's working now :). Thank you for your patience!!
Hello,
I'm trying to do this as well. I have this function:
function render_shortcode() {
$value = rwmb_meta( 'presto_video_shortcode' );
echo do_shortcode( wpautop( $value ) );
}
the shortcode value is input to the WYSIWYG field:
https://drive.google.com/open?id=13GWZL7k9qLUzgyCaABrUqonh9PRApO_Y&usp=drive_fs
The code is turned on in WPCodeBox:
https://drive.google.com/open?id=13HTHCjKId9AEXOj24Yj0YRr0aGX8CWxK&usp=drive_fs
I've checked to make sure the code signature in Bricks is valid and is added to the theme.
I've got two elements in a query loop: Code and Shortcode and neither are rendering the shortcode.
The Code elmement loads, but no code is rendered. The shortcode doesn't load. I've got my_custom_function for "hello world" in there to make sure I know echo is working.
I must be doing something simply wrong...any suggestions would be very much appreciated.
Meant to include a link: https://artsworcesterdev.milkrow.com/exhibition/solo-show-name-title/
Same here, can MB support provide some insight into how this can be achieved? Typically I've included shortcodes inside a WYSIWYG and displayed them with no issues, but not sure how to best approach this in Metabox.