Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在wordpress页面中隐藏完整的注释_Wordpress - Fatal编程技术网

如何在wordpress页面中隐藏完整的注释

如何在wordpress页面中隐藏完整的注释,wordpress,Wordpress,我已关闭页面中的评论,但页面中仍显示以下行。如何禁用这些行。有人请帮帮我 sankar于2010年10月12日发布 注释关闭|编辑 注释已关闭。您需要编辑模板中显示该注释的行。您使用的是什么版本的WP 在WP 3+和之前的版本中,您只需转到仪表板,单击页面,单击相关页面的编辑,向下滚动到标有“讨论”的部分,然后取消选择“允许评论和允许trackbacks&pingbacks”框。然后将附加到页面上的任何评论丢弃 如果你实际上是指文章而不是页面,那么Paul是正确的,因为对主题进行一次小的编辑是必

我已关闭页面中的评论,但页面中仍显示以下行。如何禁用这些行。有人请帮帮我

sankar于2010年10月12日发布 注释关闭|编辑
注释已关闭。

您需要编辑模板中显示该注释的行。

您使用的是什么版本的WP

在WP 3+和之前的版本中,您只需转到仪表板,单击页面,单击相关页面的编辑,向下滚动到标有“讨论”的部分,然后取消选择“允许评论和允许trackbacks&pingbacks”框。然后将附加到页面上的任何评论丢弃

如果你实际上是指文章而不是页面,那么Paul是正确的,因为对主题进行一次小的编辑是必要的。注意:只要有可能,使用子主题执行此操作,这样您就不会意外地敲打主主题

假设您使用的是WP 3和默认的Twenty-Ten主题,请编辑WP-content/themes/Twenty-Ten/comments.php或创建子主题,复制comments.php,然后继续

comments.php,第70行,内容如下:

if ( ! comments_open() ) :
将其更改为:

if ( 0 && ! comments_open() ) :
这有效地杀死了输出后的行,即关闭注释的行,但没有完全删除它。显然,如果您使用的是不同的主题,那么您必须在comments.php中找到适合自己的行


请注意,这是一个快速和肮脏的黑客将影响所有的职位。如果您只想对选定的帖子执行此操作,那么您需要做一些更为复杂的事情。

最简单的方法是在theme/page.php中找到以下行并删除或注释它

<?php comments_template( '', true ); ?>

转到Wordpress页面-单击快速编辑,您将看到为评论打勾的选项,您可以避免打勾

yourdomainname.com/wp admin/edit.php?post_type=page

然后


单击每个页面的快速编辑。

将此代码添加到function.php文件中

// 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');

您可以编辑页面模板。搜索获取模板部分“评论”并将其删除

可能是superuser.com的一个案例。