我已尝试添加comments.php
到我的自定义主题,这样我就可以删除网站字段,这样我就可以编辑字段的默认值并删除标签。当我添加comments.php
我所有的评论都消失了,这些评论也不再有用了。我不知道如何进行这些修改。
我试过编辑comments-template.php
但是删除该文件中的字段并不会将其从站点中删除,我假设它已经在数据库中了。
我是PHP新手,所以关于如何编辑这些文本字段的任何细节都将非常好。
我已尝试添加comments.php
到我的自定义主题,这样我就可以删除网站字段,这样我就可以编辑字段的默认值并删除标签。当我添加comments.php
我所有的评论都消失了,这些评论也不再有用了。我不知道如何进行这些修改。
我试过编辑comments-template.php
但是删除该文件中的字段并不会将其从站点中删除,我假设它已经在数据库中了。
我是PHP新手,所以关于如何编辑这些文本字段的任何细节都将非常好。
有点晚了,但您也可以将以下内容添加到主题的功能中。php文件:
/** Comment Form Function Defaults */
add_filter(\'comment_form_defaults\',\'my_comment_defaults\');
function my_comment_defaults($defaults) {
global $user_identity, $id;
if ( isset($post_id) )
$id = $post_id;
else
$post_id = $id;
$commenter = wp_get_current_commenter();
$req = get_option( \'require_name_email\' );
$aria_req = ( $req ? " aria-required=\'true\'" : \'\' );
$fields = array(
\'author\' => \'<div class="comment-form-author">\' . \'<label for="author">\' . __( \'Name:\' ) . ( $req ? \' <span class="required">*</span>\' : \'\' ) .
\'</label><input id="author" name="author" type="text" value="\' . esc_attr( $commenter[\'comment_author\'] ) . \'" size="30"\' . $aria_req . \' /></div>\',
\'email\' => \'<div class="comment-form-email"><label for="email">\' . __( \'Email:\' ) . ( $req ? \' <span class="required">*</span>\' : \'\' ) .
\'</label><input id="email" name="email" type="text" value="\' . esc_attr( $commenter[\'comment_author_email\'] ) . \'" size="30"\' . $aria_req . \' /></div>\',
\'url\' => \'\',
);
$required_text = sprintf( \' \' . __(\'Required fields are marked %s\'), \'<span class="required">*</span>\' );
$defaults = array(
\'fields\' => apply_filters( \'comment_form_default_fields\', $fields ),
\'comment_field\' => \'<div class="comment-form-comment"><label for="comment">\' . _x( \'Comment:\', \'noun\' ) . \' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></div>\',
\'must_log_in\' => \'<p class="must-log-in">\' . sprintf( __( \'You must be <a href="%s">logged in</a> to post a comment.\' ), wp_login_url( apply_filters( \'the_permalink\', get_permalink( $post_id ) ) ) ) . \'</p>\',
\'logged_in_as\' => \'<p class="logged-in-as">\' . sprintf( __( \'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>\' ), admin_url( \'profile.php\' ), $user_identity, wp_logout_url( apply_filters( \'the_permalink\', get_permalink( $post_id ) ) ) ) . \'</p>\',
\'comment_notes_before\' => \'<p class="comment-notes"><em>Note: </em>\' . __( \'Your email address will not be published.\' ) . ( $req ? $required_text : \'\' ) . \'</p>\',
\'comment_notes_after\' => \'<p class="form-allowed-tags">\' . sprintf( __( \'You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: %s\' ), \' <code>\' . allowed_tags() . \'</code>\' ) . \'</p>\',
\'id_form\' => \'commentform\',
\'id_submit\' => \'submit\',
\'title_reply\' => __( \'Leave a Reply\' ),
\'title_reply_to\' => __( \'Leave a Reply to %s\' ),
\'cancel_reply_link\' => __( \'Cancel reply\' ),
\'label_submit\' => __( \'Post Comment\' ),
);
return $defaults;
}
这可能有点过头了,但它还可以让您控制注释表单的其他字段和属性。您的问题有多种解决方案。
使用CSS
戏法
使用#commentform .comment-form-url {display:none;}
用于不显示网站字段。
注释代码
查看主题的评论。php,用于类似以下行:
<p><input type="text" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="22" tabindex="3" />
<label for="url"><small>Website</small></label></p>
p、 s.编辑前始终先备份文件。
3、使用以下教程
Wordpress How To Remove The Website Field From The Comment Form
我正在尝试发布到循环。php模板文件,但由于某种原因,它不会通过,通常它应该可以工作,但它不是。有没有其他方法来完成这项工作?这是我索引中的内容。主题的php文件。$(\'.load_more_cont a\').live(\'click\', function(e) { leftwrapper = \'THIS IS WORKING\'; $.ajax({ url: \"<?php blogin