DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Are you using different page templates on your WordPress theme? If yes, here is a cool hack that allow you to embed a page into another page.

Paste the code below within the loop. Make sure to update page ID on line 1!

<?php $recent = new WP_Query("page_id=**ID**"); while($recent->have_posts()) : $recent->the_post();?>
       <h3><?php the_title(); ?></h3>
       <?php the_content(); ?>
<?php endwhile; ?>

Thanks to CSS Tricks for the tip!



  1. Usefull,
    But do not forget to call the function wp_reset_postdata(); after the endwhile so the main query will not be overridden :).


  2. I’ve used an alternative solution in the past with success:


    Just throwing it out there as another option.

  3. This trick is seems to be easy but can you tell me what is the advantage of embedding one WordPress page to another? I have done it with my one WordPress page.

    And when I put the wp_reset_postdata(); it gives error at line 40 .

  4. Hi @Tushar try wp_reset_db() or $wpdb->flush().

    hope that helps.

Leave a Comment

Your email address will not be published. Required fields are marked *