php - 如何删除评论中的电子邮件和网站 ((Wordpress))

标签 php wordpress comments

如何在 Wordpress 中删除回复中的电子邮件和网站部分?
像这样:http://sceper.eu/2011/10/manson-family-blood-on-the-wall-2011-cr.html
只见 Name (leave blank for Anonymous) 在留言中

我使用的是 wordpress 3.2.1
并使用默认的 Wordpress 评论

(( public_html/wp-includes/comment.php



public_html/wp-includes/comment-template.php ))

我从 omment-template.php 中删除了这段代码

'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
        'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
                    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',

但这不行
我认为仅删除此代码是不够的!

现在我该怎么办?

最佳答案

  • 使用 Windows 中的记事本应用程序创建此插件,并记住使用 .php 扩展名保存文件,例如:removeurl.php
  • 将以下代码复制并粘贴到步骤 1 中创建的文件中
    <?php
    /*
    Plugin Name: Remove Website Field
    Description: Removes the website field from the comments form
    */
    add_filter('comment_form_default_fields', 'url_filtered');
    function url_filtered($fields)
    {
      if(isset($fields['url']))
       unset($fields['url']);
      return $fields;
    }
    
    ?>
    

  • 插件信用转到 TechHacking.com
  • 保存更改并通过 FTP 或 Web 主机文件管理器将其上传到/wp-content/plugins/目录
  • 转到 wordpress 管理区域中的插件菜单选项并激活插件。通过这个简单的技巧,您将从评论表单中删除网站字段。

  • 如果在任何情况下插件不起作用或功能不起作用,您也可以使用此方法,我在很多自定义工作中都使用了此方法,并且证明它非常有效,没有任何问题。
    为此,请打开您的主题主 css(样式表)复制并粘贴以下代码

    #commentform #url, #commentform #url +label {display:none;}
    

    来源:http://www.shariff.org/remove-website-field-comment-form.html

    关于php - 如何删除评论中的电子邮件和网站 ((Wordpress)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7953160/

    相关文章:

    javascript - 如何获取调用表单的按钮

    javascript - 如何使用 CORS 飞行前请求处理自定义 header ? AJAX-代码点火器

    javascript - 服务器端 URL 返回空响应

    wordpress - 无需 FTP 上传主题

    c# - WooCommerce 数据。 C#

    c# - 注释代码 C# visual studio 最佳实践

    c - 在 vim 中,如何删除所有的 C 和 C++ 注释?

    django - 通过 django 评论获取 django 中评论最多的帖子

    javascript - 发送 AJAX 请求不适用于所有页面

    php - 包含、扩展、使用、宏、嵌入 Twig 之间的区别