我向我的网站添加了博客功能。这是在WP的帮助下完成的。因此,现在我可以在我的博客上添加/删除/ etc帖子了。
但是我也想从WP中获取整个评论部分。不幸的是我仍然没有做到。评论或评论部分没有出现。有人尝试过吗?
到目前为止,我到了:
<?php
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
...
<div id="content-blog" class="flex">
<div class="container">
<div class="row">
<div class="col">
<div id="prispevek">
<?php
$number_of_posts = 5;
$args = array( 'numberposts' => $number_of_posts );
$args2 = array('post_id' => $number_of_posts);
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent_post ) {
//echo "<span>".$recent_post['post_date']."</span> <br>";
$comments = get_comments( $args2 );
echo "<h3>".$recent_post['post_title']."</h3>";
echo "<p>".$recent_post['post_content']."</p><br><br>";
echo $comments->comment_content;
}
?>
</div>
</div>
</div>
</div>
</div>
?>
有人可以帮忙吗?