When you’re building a theme for WordPress, you may need to get the content of a specific post using the ID as a filter. Most of the time you get a post’s content through the get_post_content function inside a Loop.
However, when you need to retrieve a post’s information outside the loop context or at a separate point
in the application, the best solution is to use the get_post_field('field-name'), $postId) function.
Right below you can check an example of retrieving a post’s content by ID:
| |
You can find more details about this function in the official WordPress documentation.