Get WordPress page content from Post ID using get_post()

Published on Mar 14, 2015 & tagged in WordPress

We can simply extract single Page, Post or any custom post type content from its ID using get_post() function.

<?php
$post = get_post($id); //assuming that you already have Post ID ($id)
setup_postdata($post);

// display the post here
the_title();
the_excerpt();
the_post_thumbnail();

wp_reset_postdata();
?>

Do you need any help on WordPress?

I'm happy to help you. Just fill the form on contact page & I will get back to you within few hours.

Recent Posts

  1. The add_image_size() function - WordPress best practices
  2. Remove page title using filter - WordPress
  3. Comment out code in Liquid Template Language
  4. Remove Plugin Stylesheets and Scripts - WordPress
  5. Get blog page URL - WordPress