Duane Blake

Front end developer

Multiple WordPress Pages on One Page

One of the guys in the office was working on a WordPress project, Which led to a interesting question how in wordpress can you embed multiple pages on one page.

Multiple WordPress Pages on One Page

After doing some looking through the WordPress codex, there is already a function built in the wordpress core to do this it is called get_page. What the get_page does is allows you to pull the contents of the page as an object.

To do this you need the wordpress Page ID, which you can grab from where you edit the page template, in the screenshot below.

Wordpress Page Id Screen

Place the following code on your page


<?php

$page_id = 42; //Your Page ID $page_data = get_page( $page_id );
// Displays the title echo '<h1>'. $page_data->post_title .'</h1>';
// Displays the content echo apply_filters('the_content', $page_data->post_content); ?>

If you know have any other ways to create multiple wordpress pages on one page please drop me a message or leave a comment below.

Further Reading

WordPress Codex on get page

Leave a comment

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