开发者

Get wordpress comments without trackbacks?

开发者 https://www.devze.com 2023-04-12 07:38 出处:网络
I can get the wordpress comments list using get_comments. For example: $comments = get_comments(\'status=approve&number=10\');

I can get the wordpress comments list using get_comments. For example:

$comments = get_comments('status=approve&number=10');

It re开发者_运维问答turns the trackbacks also. Is it possible to get only human comments (without trackbacks etc)? Thanks.


I believe:

$comments = get_comments('status=approve&number=10&type=comment');

Check out the documentation reference, though in the case of get_comments() it's not particularly helpful.

Also, another possible syntax which I find cleaner, is that the above syntax is equivalent to:

$args = array(
    'status' => 'approve',
    'number' => 10,
    'type' => 'comment',
);
$comments = get_comments( $args );

The $args array defines the constraints you want when getting the comments.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号