Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Shelob9/d49f0e2d20b72d582c65 to your computer and use it in GitHub Desktop.
Save Shelob9/d49f0e2d20b72d582c65 to your computer and use it in GitHub Desktop.
Not totally tested yet examples of how to use Caldera Metaplate 0.3.0-b1 https://github.com/CalderaWP/caldera-metaplate
<?php
/**
* Load the template data from a file (file must be .html or .htm )
*/
//load from child theme or parent theme
$file = 'template.html';
echo caldera_metaplate_from_file( $file, $post_id );
//or use absolute patth
//$file = __FILE__ . '/template.html';
$file = dirname(__FILE__) . '/template.html';
echo caldera_metaplate_from_file( $file, $post_id );
//above examples willl pull meta fields by $post_id
//alternatively pass an array of data to use with third arg
$file = 'template.html';
$template_data = array(
'hats' => 'Many Hats',
'shoes' => 'No shoes',
'shirts' => array(
'blue',
'red'
)
);
echo caldera_metaplate_from_file( $file, null, $template_data );
<?php
/**
* Define a template in PHP and render with a Post's data.
*/
$metaplate[ 'html' ][ 'code' ] = 'Title: {{post_title}}<br />Shoes: {{shoes}}';
echo caldera_metaplate_render( $metaplate, 42 );
//note that the second argument ^^ is post ID, and is optional when global $post is set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment