2011-12-18 78 views
0

我從這裏的某處得到這段代碼,只顯示作者在儀表板中的評論。但它甚至沒有在作者儀表板上顯示任何單個評論或作者帖子。只顯示作者對他們的評論WordPress的儀表板

請幫我改正它。

function my_plugin_get_comment_list_by_user($clauses) { if (is_admin()) { global $user_ID, $wpdb; $clauses['join'] = ", wp_posts"; $clauses['where'] .= " AND wp_posts.post_author = ".$user_ID." AND wp_comments.comment_post_ID = wp_posts.ID"; }; return $clauses; }; // Ensure that editors and admins can moderate all comments if(!current_user_can('edit_others_posts')) { add_filter('comments_clauses', 'my_plugin_get_comment_list_by_user'); } 

回答

0

使用這種被一些自定義:

<?php 
    $my_id = 7; 
    $comment_id_7 = get_comment($my_id, ARRAY_A); 
    $name = $comment_id_7['comment_author']; 
?> 

ALSE使用本:

<div class="commentlist"><?php wp_list_comments(array('style' => 'div')); ?></div> 
+0

可能是它我的錯誤我沒有張貼整個代碼..下面是完整的代碼。我正在尋找儀表板評論部分,而不是前端。此代碼用於在Dashboard Comment部分顯示作者的帖子評論。所以作者只能看到他/她的帖子評論,並且可以適中。但是,使用下面的代碼,即使作者自己的帖子發表評論,它也會消失所有評論。 – 2011-12-18 11:17:26

+0

這裏是我用的是什麼碼... '函數my_plugin_get_comment_list_by_user($條款){ 如果(is_admin()){ 全球$ USER_ID,WPDB $; $子句['join'] =「,wp_posts」; $ clauses ['where']。=「AND wp_posts.post_author =」。$ user_ID。「AND wp_comments.comment_post_ID = wp_posts.ID」; }; 返回$子句; }; //如果(!current_user_can('edit_others_posts')){ add_filter('comments_clauses','my_plugin_get_comment_list_by_user'); //確保編輯和管理員可以調整所有評論 ; }' – 2011-12-18 11:17:56