自定义注释类型wordpress
当我插入注释时,我使用以下代码自定义注释类型wordpress,wordpress,Wordpress,当我插入注释时,我使用以下代码 $data = array( 'comment_post_ID' => $postid, 'comment_content' => 'User Review', 'comment_type' => 'review', 'user_id' => $userid, 'comment_date' => $time, 'comment_approved' => 1, ); $commen
$data = array(
'comment_post_ID' => $postid,
'comment_content' => 'User Review',
'comment_type' => 'review',
'user_id' => $userid,
'comment_date' => $time,
'comment_approved' => 1,
);
$commentid = wp_insert_comment($data);
如果我试图根据“评论类型”获取这些评论,我不会得到结果
$args = array(
'user_id' => $userid,
'post_type' => 'review'
);
$comments = get_comments($args);
get_注释不能用于获取特定类型的注释
如何获得类型审查的评论 您可以编写一个自定义查询来获取review类型的注释
<?php
global $wpdb;
$query = "SELECT *
FROM $wpdb->comments
WHERE $wpdb->comments.user_id =$userid AND $wpdb->comments.comment_type = 'review'";
$results = $wpdb->get_results($query);
print_r($results);
?>
您可以编写一个自定义查询来获取review类型的注释
<?php
global $wpdb;
$query = "SELECT *
FROM $wpdb->comments
WHERE $wpdb->comments.user_id =$userid AND $wpdb->comments.comment_type = 'review'";
$results = $wpdb->get_results($query);
print_r($results);
?>
试试这段代码,
我希望这会有所帮助
$args = array(
'user_id' => $userid,
'type' => 'review'
);
$comments = get_comments($args);
试试这个代码,
我希望这会有所帮助
$args = array(
'user_id' => $userid,
'type' => 'review'
);
$comments = get_comments($args);
医生很清楚,兄弟post_类型
专门用于post/page/CPT等。。。而类型
是用于注释类型
…文档非常清晰,可供选择post_类型
专门用于post/page/CPT等。。。而类型
用于注释类型
。。。