Caldera Metaplate, by default operates in “Autoload” mode, which allows it to automatically output a Metaplate, before, after or in place of a post’s content. You can also output a Metaplate using the shortcode caldera_metaplate
or the function caldera_metaplate_render()
. This document details how to use each of these methods for outputting your Metaplate.
Using The Shortcode
The caldera_metaplate
shortcode accepts 5 parameters. They are:
- “id” – The ID of the Metaplate.
- Either this parameter or the “slug” parameter must be used.
- If “id” is used, “slug” is ignored.
- “slug” – The Slug of the Metaplate.
- Either this parameter or the “id” parameter must be used.
- Only works if “id” is not used.
- “post_id” – The ID of a post, in any post type, to use to render the Metaplate.
- This parameter is not required if used in post content, or anywhere else that the global $post object is set.
- ‘template_code’ – If used will override the default Template stored in the Metaplate settings
- ‘css’ – If used will override the default CSS stored in the Metaplate.
The caldera_metaplate
shortcode can also enclose content, which we be used in place of post content, if the {{content}}
tag is used in the Metaplate.
Using The Function
If you prefer to output your Metplate using PHP, you can also use the caldera_metaplate_render()
function. If used inside the loop or anywhere else the global $post object is set, it only requires it’s first parameter, which is the slug or id of the metaplate. If used outside of the loop, or to use a diffrent post’s data to render the Metaplate, you must pass that ID to the second parameter of the function:
<?php //Will output current post in loop, or nothing if used outside of the loop, using the Metaplate "food" echo caldera_metaplate_render( 'food' ); //Will output the post with the ID of 42, using the Metaplate "food" echo caldera_metaplate_render( 'food', 42 );