开发者

post ID from array ( $post->ID )

开发者 https://www.devze.com 2023-03-28 08:34 出处:网络
The get_post returns the post ID as an array ( $post->ID ) with multiple values. I nee开发者_运维问答d post id of particular post, how to extract this?you are using the correct function for this: h

The get_post returns the post ID as an array ( $post->ID ) with multiple values. I nee开发者_运维问答d post id of particular post, how to extract this?


you are using the correct function for this: http://codex.wordpress.org/Function_Reference/get_post

if you were using get_posts(); , then that would return multiple ID's, but using get_post would only return an object or array containing a single post. e.g.:

<?php
$my_post_id = 20;
$my_post = get_post($my_post_id); 
$title = $my_post->post_title;
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消