Below, you’ll find a detailed guide on how to add the WP-Stateless – Google Cloud Storage Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP-Stateless – Google Cloud Storage Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the WP-Stateless – Google Cloud Storage Plugin and the shortcodes it provides:
"WP-Stateless – Google Cloud Storage is a powerful WordPress plugin. It seamlessly syncs your website's media library with Google Cloud Storage, ensuring fast, reliable, and secure storage."
- [rwmb_meta]
WP-Stateless [rwmb_meta] Shortcode
The WP-Stateless plugin shortcode ‘rwmb_meta’ retrieves and presents metadata from a specified object or post. The ‘rwmb_meta’ shortcode allows customization of the id, object_id, attribute, and render_shortcodes attributes. If the ‘id’ attribute is empty, it returns an empty string. The ‘render_shortcodes’ attribute determines whether the retrieved value will be parsed for shortcodes.
Shortcode: [rwmb_meta]
Parameters
Here is a list of all possible rwmb_meta shortcode parameters and attributes:
id
– The unique identifier of the meta field.object_id
– The ID of the post or user to retrieve the meta from.attribute
– Any additional attribute to be applied to the meta field.render_shortcodes
– If ‘true’, any shortcodes in the meta field value will be executed.
Examples and Usage
Basic example – Displays the value of a specific meta field by referencing the field ID.
[rwmb_meta id="field_id" /]
Advanced examples
Display the value of a specific meta field by referencing the field ID, and specify the object ID to which the field belongs. This is useful when you want to display meta information for a specific post or page.
[rwmb_meta id="field_id" object_id="123" /]
Display the value of a specific meta field by referencing the field ID, specify the object ID, and disable the rendering of other shortcodes within the value. This is useful when you want to display the raw value of a meta field, without processing any shortcodes that it may contain.
[rwmb_meta id="field_id" object_id="123" render_shortcodes="false" /]
Remember, the ‘id’ attribute refers to the meta field ID, ‘object_id’ refers to the ID of the post or page to which the field belongs, and ‘render_shortcodes’ determines whether other shortcodes within the field value should be processed (set to ‘true’ by default).
PHP Function Code
In case you have difficulties debugging what causing issues with [rwmb_meta]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'rwmb_meta', [ $this, 'register_shortcode' ] );
Shortcode PHP function:
function register_shortcode( $atts ) {
$atts = wp_parse_args( $atts, [
'id' => '',
'object_id' => null,
'attribute' => '',
'render_shortcodes' => 'true',
] );
RWMB_Helpers_Array::change_key( $atts, 'post_id', 'object_id' );
RWMB_Helpers_Array::change_key( $atts, 'meta_key', 'id' );
if ( empty( $atts['id'] ) ) {
return '';
}
$field_id = $atts['id'];
$object_id = $atts['object_id'];
unset( $atts['id'], $atts['object_id'] );
$value = $this->get_value( $field_id, $object_id, $atts );
$value = 'true' === $atts['render_shortcodes'] ? do_shortcode( $value ) : $value;
return $value;
}
Code file location:
wp-stateless/wp-stateless/vendor/wpmetabox/meta-box/inc/shortcode.php
Conclusion
Now that you’ve learned how to embed the WP-Stateless – Google Cloud Storage Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply