wordpress - 找到评论的帖子标题

标签 wordpress comments

我正在尝试创建一个插件,类似于评论存档。 我看过get_comment() .

我希望显示评论的来源,特别是附加评论的帖子的标题。这是我的代码的一部分:

if ( $comments ) {
  foreach ( $comments as $comment ) {
    // here you can display the comment in the way you want

    echo 'from: ' . $comment->i want comment post title here . '<br/>';
    echo '<p>' . $comment->comment_content . '</p>';
  }
}

如何做到这一点?

最佳答案

具体操作方法如下:

<?php
    if ( $comments )
        foreach($comments as $comment){
            // here you can display the comment in the way you want

            echo 'from: ' . get_the_title($comment->comment_post_ID) . '<br/>';
            echo '<p>' . $comment->comment_content . '</p>;
        }
?>

关于wordpress - 找到评论的帖子标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20039100/

相关文章:

PHP ( Wordpress) - 选择多个 - 显示 "selected"状态不工作

php - 将 CSS 类分配给第一个和第三个 html 元素

javascript - $.post 不能与 $J = jQuery.noConflict(); 结合使用

php - 在 PHP 中制作评论部分的安全方法

performance - 注释会影响Perl的性能吗?

图片未显示在安全页面上?

wordpress - WP 查询循环通过在主页上工作但不在搜索页面上的自定义帖子类型

php - Wordpress 独立评论页面 - 带分页

swift - Xcode + swift : Is it possible to create custom comment marks?

python - 常见的Python文件头格式是什么?