Skip to content

Instantly share code, notes, and snippets.

@sbruner
Last active June 29, 2016 15:43
Show Gist options
  • Save sbruner/4065b29164835f207b3cec6ddf0ea9f9 to your computer and use it in GitHub Desktop.
Save sbruner/4065b29164835f207b3cec6ddf0ea9f9 to your computer and use it in GitHub Desktop.
<!-- Display dynamic html markup in a textarea for easy copying and pasting -->
<!-- start object buffering -->
<?php ob_start(); ?>
<!-- create your template -->
<!-- Use the get_post_meta() function to get your data -->
<table style="width:100%">
<tr>
<th><?php echo get_post_meta(get_the_ID(), 'heading_one');?></th>
<th><?php echo get_post_meta(get_the_ID(), 'heading_two');?></th>
</tr>
<tr>
<td><?php echo get_post_meta(get_the_ID(), 'content_one');?></td>
<td><?php echo get_post_meta(get_the_ID(), 'content_two');?></td>
</tr>
</table>
<!-- get the contents of the buffer, and assign to $content -->
<?php $content = ob_get_contents(); ?>
<!-- end object buffering -->
<?php ob_end_clean(); ?>
<?php
// Use a Piklist textarea field to display your contents, for easy copying and pasting.
piklist('field', array(
'type' => 'textarea'
,'field' => 'my_embed_code'
,'template' => 'field' // This removes the label and only shows the field for more real estate.
,'value' => $content // This is the variable that holds the bufferd content.
,'attributes' => array(
'rows' => 10
,'cols' => 50
,'class' => 'large-text'
)
));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment