caldera_metaplate_render

Render and return a metaplate.

Description

(string|null) caldera_metaplate_render( (string|array) $metaplate, (null) $post_id = null ); 

Returns (string|null)

The rendered content if it was able to be rendered.

Parameters (2)

0. $metaplate (string|array)
metaplate name or slug to render
1. $post_id — Optional. (null) => null
To get meta data from/ if null, use the $post global.

Usage

  1. if ( !function_exists( 'caldera_metaplate_render' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'metaplate/vendor/calderawp/metaplate-core/src/functions.php'; 
  3.  
  4. // metaplate name or slug to render 
  5. $metaplate = null; 
  6.  
  7. // to get meta data from/ if null, use the $post global. 
  8. $post_id = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = caldera_metaplate_render($metaplate, $post_id); 
  12.  

Defined (1)

The function is defined in the following location(s).

/vendor/calderawp/metaplate-core/src/functions.php  
  1. function caldera_metaplate_render( $metaplate, $post_id = null ) { 
  2. if ( is_string( $metaplate ) ) { 
  3. $metaplate = calderawp\metaplate\core\data::get_metaplate( $metaplate ); 
  4.  
  5.  
  6. if ( ! is_array( $metaplate ) ) { 
  7. return; 
  8.  
  9.  
  10. $template_data = null; 
  11. if ( ! is_null( $post_id ) ) { 
  12. $template_data = calderawp\metaplate\core\data::get_custom_field_data( $post_id ); 
  13.  
  14. $render = new calderawp\metaplate\core\render(); 
  15. $output = $render->render_metaplate( null, array( $metaplate ), $template_data ); 
  16. if ( is_string( $output ) ) { 
  17. return $output; 
  18.  
  19.