WordPress.org

Ready to get started?Download WordPress

Codex

tr:Fonksiyon Referans/get post

Contents

Description

ID numarası belirtilen değerlerin meta valua bilgilerini gösterir. Bunlar başlık, yorum sayısı, yayınnlama tarihi, içerik gibi yazı değerleri olabilirler.

Usage

<?php get_post$post_id$output ); ?> 

Parameters

$post_id
(integer) (required) The ID of the post you'd like to fetch. You must pass a variable containing an integer (e.g. $id). A literal integer (e.g. get_post(7)) will cause a fatal error (Only variables can be passed for reference or Cannot pass parameter 1 by reference).
Default: None
$output
(string) (optional) How you'd like the result.
  • OBJECT - (default) returns an object
  • ARRAY_A - Returns an associative array of field names to values
  • ARRAY_N - returns a numeric array of field values
Default: OBJECT

Example

Şimdi 7 ID numarasına sahip yazının başlık bilglerini gösterelim:

<?php
$my_id 
7;
$post_id_7 get_post($my_id); 
$title $post_id_7->post_title;
?> 

Alternatively, specify the $output parameter:

<?php
$my_id 
7;
$post_id_7 get_post($my_idARRAY_A);
$title $post_id_7['post_title'];
?> 

<?php
##    Correct: pass a dummy variable as post_id
$the_post = & get_post$dummy_id );
    
##    Incorrect: literal integer as post_id
$the_post = & get_post);
//    Fatal error: 'Only variables can be passed for reference' or 'Cannot pass parameter 1 by reference'
?>

Return

In case of failure, this function returns null.

The fields returned are:

ID 
(integer) Yazı ID
post_author 
(integer) Yazar bilgileri
post_date 
(string) Yayınlanma tarihi (YYYY-MM-DD HH:MM:SS)
post_date_gmt 
(string) Yayınlanma tarihi (YYYY-MM-DD HH:MM:SS)
post_content 
(string) Yazı içeriği
post_title 
(string) Yazı başlığı
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) Yazı durumu (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

Source File

get_post() is located in wp-includes/post.php and wp-app.php.

References

Related

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.