One line to include the content from one page into another page
Do you need to quickly include text or other content from a page into a larger page? Or you can even set up ‘partial’ pages specifically to allow some part of a complex template file to be user-editable, like an ‘intro text’ area. Here’s the line:
<?= get_page_by_path('page-to-include')->post_content; ?>
'page-to-include'
here is the page slug (URL). You can use child pages by putting in their path, like 'parent/child-to-include'
This does use a few PHP shortcuts to get it into one line. The unabbreviated, perhaps slightly more readable, version is:
<?php
$include = get_page_by_path('page-to-include');
echo $include->post_content;
?>