嗨,我用这个代码加载特定帖子的内容和信息:
if ($actual_link == $wpbase){
$recent_posts = wp_get_recent_posts('1');
foreach( $recent_posts as $recent ){
echo '<article id="post-'.$recent["ID"].'"><h1>' .
$recent["post_title"] .
'</h1>' .
apply_filters('the_content', $recent["post_comments"]) .
'</article><aside>' .
$recent["post_content"].
'</aside>';
};
}
但是不知何故,最后的表达式CCD_ 1不返回任何内容。甚至连原始评论文本都没有。我做错什么了吗?我尝试了不同的语法,也使用了wp_list_comments( $args );
,但从未真正起作用。
有什么办法吗?谢谢你的帮助!
wp_get_recent_posts
不返回post注释,请查看get_post
的返回值以查看可用字段。
wp_list_comments
将显示一个注释列表,但您应该在wordpress循环中使用它。
但是,您可以使用get_comments来获得一组注释,看看codex上的示例。
PS:不赞成使用wp_get_recent_posts
的方式,应该使用数组而不是'1'