How to Include a WordPress Page on Another WP Page or Part of Your Theme (without using a Plugin)
So you have some content from one WordPress post or page and you want to include it elsewhere in your theme. Perhaps you have a “Store Hours” page that you’d like to be able to only update once and have it show in various spots of your website, not just on that particular page.
The following snippet of code shows you how to tell PHP to grab a particular page via
get_pages, and then sets two variables depending on that page’s content and title.
The last line shows you how to output the content.
$include = get_pages('include=4177');
$content = apply_filters('the_content',$include->post_content);
$title = apply_filters('the_title',$include->post_title);
echo '<h1>'.$title.'</h1>'; echo $content;
Remember to change the
4177 to whatever the ID of your particular page is, and note that you don’t need to keep the last “echo” line in there, you could use that elsewhere in your template.
Up Next: Basic Web Design Templates