WordPress :: Include the content of one page on another page

Posted by Gav on 26 November 2011 | 0 Comments

Tags:

Have you ever wanted to include the content from one page into another page in WordPress. Perhaps you want an editable sidebar! This is how to achieve this.

Below is a simple code snippet that you can put into your page.php file or whereever you need it.

<?php 
	$sidebar_page_id = 110; 
	$sidebar_page = get_page( $sidebar_page_id ); 
	$sidebar_content = apply_filters('the_content', $sidebar_page->post_content); 
?>


You must pass a variable to the get_page function. If you do something like $sidebar_page = get_page( 110 ); wordpress will drop an error on yo a$$.


Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page | RSS feed for all comments