Posts Tagged ‘wordpress post id’

WordPress Knowledge Base:

1. How to call a single post in wordpress template?

Wordpress function: get_post($post_id,$output);
$post_id = id of post to get content
$output = OBJECT- default an object
ARRAY_A-returns an associative array of filed names to values
ARRAY_N- returns numeric array of field values

Example 1:
$postId  = 1;
$data = get_post($postId);
$postTitle = $data->post_title;
$postContent = $data->post_content;

Example 2:
$postId  = 1;
$data = get_post($postId,ARRAY_A);
$postTitle = $data-[‘post_title’];
$postContent = $data[‘post_content’];

Returned Fields are:

ID (integer) The post ID
post_author (integer) The post author’s ID
post_date (string) The datetime of the post (YYYY-MM-DD HH:MM:SS)
post_date_gmt (string) The GMT datetime of the post (YYYY-MM-DD HH:MM:SS)
post_content (string) The post’s contents
post_title (string) The post’s title
post_category (integer) The post category’s ID. Note that this will always be 0 (zero) from wordpress 2.1 onwards. To determine a post’s category or categories, use get_the_category().
post_excerpt (string) The post excerpt
post_status (string) The post status (publish|pending|draft|private|static|object|attachment|inherit|future|trash)
comment_status (string) The comment status (open|closed|registered_only)
ping_status (string) The pingback/trackback status (open|closed)
post_password (string) The post password
post_name (string) The post’s URL slug
to_ping (string) URLs to be pinged
pinged (string) URLs already pinged
post_modified (string) The last modified datetime of the post (YYYY-MM-DD HH:MM:SS)
post_modified_gmt (string) The last modified GMT datetime of the post (YYYY-MM-DD HH:MM:SS)
post_content_filtered (string)
post_parent (integer) The parent post’s ID (for attachments, etc)
guid (string) A link to the post. Note: One cannot rely upon the GUID to be the permalink (as it previously was in pre-2.5), Nor can you expect it to be a valid link to the post. It’s merely a unique identifier, which so happens to be a link to the post at present.
menu_order (integer)
post_type (string) (post|page|attachment)
post_mime_type (string) Mime Type (for attachments, etc)
comment_count (integer) Number of comments

Surinder Goswami | Create Your Badge

I wish to introduce myself as an individual who is always ready to learn something new and is very creative and inventive in nature. I was born and brought up in a loving, caring and religious family where I was taught the value of honesty and sincerity. I hail from Kurali(Punjab), I belongs to middle class family. I am always taught to pay prime importance to ethical and personal values of love, peace and sincerity. All members of my family are not educated and personal aim of my life is to place myself in a better position in the ever expanding corporate world.
My father has been a source of inspiration throughout my education. My parents’ support has always made me strong and encouraged me from time to time to face the big challenges in my life. In order to strengthen my goal, I have worked very hard in academics, extra curricular activities to achieve my personal development and lead my career in a meaningful way.