我不想运行任何评论查询。我不想在wordpress管理区显示任何评论。
Is this possible in any way?
EDIT: 从管理栏和所有后端部分删除指向评论的所有链接。我不想运行任何评论查询。我不想在wordpress管理区显示任何评论。
Is this possible in any way?
EDIT: 从管理栏和所有后端部分删除指向评论的所有链接。这里列出了以上所有答案,并删除了管理栏链接。只需将其添加到您的主题功能文件或将其作为插件即可。我将把它标记为一个社区维基,因为每个人的答案都是正确的,只是没有人将其全部添加到一起。
<?php
// Removes from admin menu
add_action( \'admin_menu\', \'my_remove_admin_menus\' );
function my_remove_admin_menus() {
remove_menu_page( \'edit-comments.php\' );
}
// Removes from post and pages
add_action(\'init\', \'remove_comment_support\', 100);
function remove_comment_support() {
remove_post_type_support( \'post\', \'comments\' );
remove_post_type_support( \'page\', \'comments\' );
}
// Removes from admin bar
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu(\'comments\');
}
add_action( \'wp_before_admin_bar_render\', \'mytheme_admin_bar_render\' );
?>
要删除“注释”菜单,请执行以下操作:
add_action( \'admin_init\', \'my_remove_admin_menus\' );
function my_remove_admin_menus() {
remove_menu_page( \'edit-comments.php\' );
}
这将删除对您网站上评论的支持:
add_action(\'admin_menu\', \'remove_comment_support\');
function remove_comment_support() {
remove_post_type_support( \'post\', \'comments\' );
remove_post_type_support( \'page\', \'comments\' );
}
不过,我不知道它是否会在管理部分隐藏所有评论。仪表板上的“现在”框大多是硬编码的,因此您必须隐藏该框或进行一些黑客操作以过滤掉有关“评论”的行。但它应该删除我能想到的任何地方的“评论”文本。// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, \'comments\')) {
remove_post_type_support($post_type, \'comments\');
remove_post_type_support($post_type, \'trackbacks\');
}
}
}
add_action(\'admin_init\', \'df_disable_comments_post_types_support\');
// Close comments on the front-end
function df_disable_comments_status() {
return false;
}
add_filter(\'comments_open\', \'df_disable_comments_status\', 20, 2);
add_filter(\'pings_open\', \'df_disable_comments_status\', 20, 2);
// Hide existing comments
function df_disable_comments_hide_existing_comments($comments) {
$comments = array();
return $comments;
}
add_filter(\'comments_array\', \'df_disable_comments_hide_existing_comments\', 10, 2);
// Remove comments page in menu
function df_disable_comments_admin_menu() {
remove_menu_page(\'edit-comments.php\');
}
add_action(\'admin_menu\', \'df_disable_comments_admin_menu\');
// Redirect any user trying to access comments page
function df_disable_comments_admin_menu_redirect() {
global $pagenow;
if ($pagenow === \'edit-comments.php\') {
wp_redirect(admin_url()); exit;
}
}
add_action(\'admin_init\', \'df_disable_comments_admin_menu_redirect\');
// Remove comments metabox from dashboard
function df_disable_comments_dashboard() {
remove_meta_box(\'dashboard_recent_comments\', \'dashboard\', \'normal\');
}
add_action(\'admin_init\', \'df_disable_comments_dashboard\');
// Remove comments links from admin bar
function df_disable_comments_admin_bar() {
if (is_admin_bar_showing()) {
remove_action(\'admin_bar_menu\', \'wp_admin_bar_comments_menu\', 60);
}
}
add_action(\'init\', \'df_disable_comments_admin_bar\');
这不会将其从标记本身中删除,但通过在主题的CSS中添加以下行,可以轻松隐藏WP 3.1管理栏链接(无论是从视觉上还是从屏幕阅读器中):
li#wp-admin-bar-comments { display: none; visibility: hidden; }
有一种现成的解决方案可以做到这一点。这是Frank Bültge的插件
文档:http://wpengineer.com/2230/removing-comments-absolutely-wordpress/
插件下载:https://github.com/bueltge/Remove-Comments-Absolutely
只需安装即可。无配置。
它与WP 3.5配合使用效果良好
我的单曲。php和索引。php我在这段代码中加入了注释输入例程。。。<?php if(get_option(\'allow_comments_posts\')){comments_template();} ?> 但是,当具体帖子被单独查看时。php没有选中“允许评论”,我不希望出现评论模板。我的印象是comments\\u template()例程自动管理这个,但显然我需要包装它或传递参数?