- Create the object of get_post.
- Output the title by calling the post_title variable.
Likewise, how do I get post title and content in WordPress? $post_7 = get_post( 7 ); echo $post_7->post_title; To get the post content for a post with ID 7: $post_7 = get_post( 7 ); echo $post_7->post_content; Let me know if this helped.
Also, which function get the title of the page or post? You can use the function get_the_title() to get the title of a page as a variable just by providing the ID. If you don’t provide an ID, then the function will try to fetch the ID for the current page.