WordPress get page content by id from other page or posts

In wordpress get page content by id is mainly used to get the content outside of the page calling by url

Like as if you want to call the content of the about in home page or in footer in case of wordpress theme development

Now code for the wordpress get page content by id step by step

  • First you need to get the page id better to take it in a veriable like $id=47;
  • Second get all the page or post content in a veriable passing by the page id like $post = get_page($id);
  • Finaly print or echo the page content like echo $post->post_content;

Now the sample code given below:

<?php $id=47; $post = get_page($id); echo $post->post_content;  ?>

In this post you have learned how to get wordpress get page content by id

Please provide your comment to make the site better and more useful.

Thanks for reading

Share The Post On -

Add a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.