[英]how can remove Email and Website in comments ((Wordpress))
如何刪除Wordpress中的回復中的電子郵件和網站部分? 像這樣: http : Name (leave blank for Anonymous)
在留下回復中只能看到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
由於指定的問題涉及電子郵件和網站字段,我修改了@king Tohi的答案:
<?php
/*
Plugin Name: Remove Website and Email Field
Description: Removes the website field and email 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;
}
add_filter('comment_form_default_fields', 'email_filtered');
function email_filtered($fields)
{
if(isset($fields['email']))
unset($fields['email']);
return $fields;
}
?>
希望這能拯救靈魂......
編輯:
在我的情況下禁用該字段后,電子郵件字段是強制性的,所以我不得不禁用它
settings > discussion >
取消選擇Comment author must fill out name and email
去管理員
儀表板>>設置>>討論
在這里你必須取消選中“評論作者必須填寫姓名和電子郵件”和所有設置。
試試吧 :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.