Posted By

FlashBuddy on 10/16/13



Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


WordPress Include Page or Post within another Page or Post via Templates

 / Published in: PHP

By adding this function to ones functions.php and then a call in ones page.php, single.php, home.php, index.php or custom template file. You can include on page within another.

  1. //Add to functions.php
  2. function show_post($path) {
  3. $post = get_page_by_path($path);
  4. $content = apply_filters('the_content', $post->post_content);
  5. echo $content;
  6. }
  8. //add to your page/post/template file
  9. <?php show_post('about'); // Shows the content of the "About" page. ?>
  10. <?php show_post('category/postname'); // Shows content of a Post page. ?>

Report this snippet  

You need to login to post a comment.