如何将WordPress发布的评论拉到外部页面

时间:2011-01-27 作者:Adam Merrifield

您好,我想知道是否有办法将帖子上的评论内容从wordpress拉到单独的页面。目前,这就是我所拥有的,我想用一个函数来代替它来拉评论,而不是拉评论的链接。

<?php
// Include Wordpress 
define(\'WP_USE_THEMES\', false);
require(\'./blog/wp-load.php\');
?>
<div>
<p style="font-size:18px;color:white;font-wieght:700;">Recently Asked Questions</p>
<?php query_posts(\'showposts=3\'); ?>
<?php while (have_posts()): the_post(); ?>
<div id="faq">
<a href="<?php the_permalink() ?>"><?php the_title() ?></a><br />
<?php the_time(\'F jS, Y\') ?>
<?php the_excerpt(); ?>
<?php comments_popup_link(); ?>
To see the answer to the question click <a href="<?php the_permalink() ?>">here</a>.<br /><br />
</div>
<?php endwhile; ?>
</div>
非常感谢您的帮助,谢谢。

2 个回复
最合适的回答,由SO网友:Bainternet 整理而成

添加到循环中,并用\\u permalink()函数替换它,如下所示:

<?php
// Include Wordpress 
define(\'WP_USE_THEMES\', false);
require(\'./blog/wp-load.php\');
?>
<div>
<p style="font-size:18px;color:white;font-wieght:700;">Recently Asked Questions</p>
<?php query_posts(\'showposts=3\'); ?>
<?php while (have_posts()): the_post(); ?>
<div id="faq">
<a href="<?php the_permalink() ?>"><?php the_title() ?></a><br />
<?php the_time(\'F jS, Y\') ?>
<?php the_excerpt(); ?>
<?php comments_popup_link(); ?>
<?php comments_template( \'\', true ); ?>
<br />
</div>
<?php endwhile; ?>
</div>

SO网友:Ashfame

Use get_comments() - http://codex.wordpress.org/Function_Reference/get_comments

<?php 
$comments = get_comments(\'post_id=15\');
foreach($comments as $comment) :
    echo($comment->comment_author);
endforeach;
?>
结束