Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function template(string $file, array $data) {
- if (! file_exists($file)) {
- return '';
- }
- if (! empty($data) && is_array($data)){
- extract($args);
- }
- ob_start();
- include $file;
- return ob_get_clean();
- }
- function get_post_content($id) {
- $post = get_post($id);
- $file = get_template_directory() . '/templates/post-content.php';
- $data['content'] = $post->post_content;
- echo template($file, $data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement