How to Fetch Post Data and Add Post Custom field in WP.

Possibility to fetch post data to a page template in WP

  • Instead of fetching the content of a post to a template page, I discovered how to build up the post type’s common template.
  • As a result, we may make a post using the same template.
  • This procedure is comparable to making a page template. By default, when we describe a template, we’re referring to a page template.
    As a result, for the post template, we must also describe its type (as the post).
  • We can fetch the post contents with the common term used in WordPress.
    eg: For fetching a post title, we can use the_title() function to get the title of a corresponding page. So, replace the corresponding function in PHP code to its respective places in the template. So that, it will automatically display multiple posts with the same template.

Possibility toad custom fields to a post dashboard

  • Considering the post template, there are some extra contents in the post. So, for that, there needs extra fields addon to the post. Because of the post which follows a particular structure, we need some custom fields for all posts with the same structure by default.
  • Addition of custom fields in posts can also be done using the same ACF plugin.
  • A common custom fields template needs to be creat for this purposes.
  • Make sure that the location given for custom filed template is as below:

Leave a comment

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