有人可以告诉我使用帖子 ID 获取帖子的最佳方式是什么?
我正在使用这个:
$query = query_posts('post_id='.$_GET['php_post_id']);
global $post;
foreach ($query as $post):
do stuff...
<?php endforeach;
wp_reset_query(); ?>
这将返回一个包含所有帖子的数组
get_post( $post_id, $output );
所以在实践中会是这样的:
$my_id = 7;
$post_id_7 = get_post($my_id);
有关帖子参数和字段的更多参考,请参见此处:http://codex.wordpress.org/Function_Reference/get_post http://codex.wordpress.org/Function_Reference/get_post
Update:这是最佳实践当你需要通过 id 获取单个帖子时,不需要 cicles。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)