daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Feb 19th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function template(string $file, array $data) {
  4.     if (! file_exists($file)) {
  5.         return '';
  6.     }
  7.    
  8.     if (! empty($data) && is_array($data)){
  9.         extract($args);
  10.     }
  11.    
  12.     ob_start();
  13.     include $file;
  14.     return ob_get_clean();
  15. }
  16.  
  17. function get_post_content($id) {
  18.     $post = get_post($id);
  19.     $file = get_template_directory() . '/templates/post-content.php';
  20.    
  21.     $data['content'] = $post->post_content;
  22.    
  23.     echo template($file, $data);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top