Hi I use this code to load the content and info of a specific post:
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>';
};
}
but somehow the last expression $recent["post_comments"] does not return anything. not even raw comment text. Am I doing something wrong? I tried diffent syntaxes, also using wp_list_comments( $args ); but never got it really working.
Any ideas how to get this working?
Thanks for your help!
wp_get_recent_postsdoes not return post comments, take a look atget_postreturn value to see available fields.wp_list_commentswill display a list of comments, but you should use it inside a wordpress loop.But you can use get_comments to get an array of comments, take a look at examples on codex.
PS: the way you are using
wp_get_recent_postsis deprecated, you should use an array instead of'1'