如何通过WordPress中的特殊类别过滤'edit-comments.php'中的评论?
问题描述:
如何通过WordPress中的特殊帖子类别过滤'edit-comments.php'中的评论。如何通过WordPress中的特殊类别过滤'edit-comments.php'中的评论?
add_action('pre_get_comments', 'filt_comm');
function filt_comm($query) {
$query->query_vars['??'] = ??;
}
答
如果希望只在某些类别做编辑的comments.php的东西,你可以试试这个
<?php
$category = get_the_category();
if($category[0]->cat_name == 'category name') {
//Do something here;
}
?>
+0
谢谢,但我想过滤编辑评论页面的当前查询。 – Masoomian 2013-02-20 11:51:15
入住此[搜索查询(http://wordpress.stackexchange.com/search?q = pre_get_comments + is%3Aanswer).......... – brasofilo 2013-02-20 18:09:49