RSS Feed

Get Post title and content by using post ID – WordPress

May 13, 2010 by admin 1 Comment »

Here is a code snippet for getting WordPress post title and content using script. Example uses post ID.

$my_id = 7;
$post_id_7 = get_post($my_id); 
$title = $post_id_7->post_title;
$content = $title = $post_id_7->post_content;

NOTE:
You must ONLY pass the variable containing an integer value and not the actual integer. The function receives value by reference.

$post_id is an array object:

Learn more here

 

One Response to “Get Post title and content by using post ID – WordPress”

  1. [...] Get Post title and content by using post ID – WordPress [...]

Leave a Reply