Get all page content and display in header
2 answers
Use the following code to get:
$page = get_page_by_title('TEST', OBJECT, 'page');
echo $page->post_content;
Use the following code if the page has a shortcode and text added to the page on the Contact page:
$page = get_page_by_title('Contact', OBJECT, 'page');
$page->post_content;
// will match square brackets
if (preg_match('^\[(.*?)\]^', $page->post_content))
{
echo do_shortcode($page->post_content);
}else{
echo $page->post_content;
}
Use if you have text as well as shortcode on the page replace 226 with your page id;
$id=226;
$post = get_page($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
Read: https://codex.wordpress.org/Function_Reference/get_page_by_title
+1
source to share