Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement