Last active
August 29, 2015 14:15
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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