Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wormeyman/319abae148702883aa95f2f55262f2fe to your computer and use it in GitHub Desktop.
Save wormeyman/319abae148702883aa95f2f55262f2fe to your computer and use it in GitHub Desktop.
WordPress remove website field from comment form. Known to work with Generate Press
{
"generator": "Code Snippets v2.14.0",
"date_created": "2021-01-30 18:21",
"snippets": [
{
"name": "GP Remove website field from comment form",
"desc": "Remove the website field from a WordPress comment form, this is known to work well with Generate Press. There is no need for the website field anymore it is usually only used for spammy backlinks that are going to be \"no followed\" anyways.",
"tags": ["php", "WordPress", "Comments"],
"scope": "global",
"code": "add_action( 'after_setup_theme', 'tu_add_comment_url_filter' );\nfunction tu_add_comment_url_filter() {\n add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 );\n}\n\nfunction tu_disable_comment_url($fields) {\n unset($fields['url']);\n return $fields;\n}",
"priority": "10"
}
]
}
<?php
/**
* GP Remove website field from comment form
*/
add_action( 'after_setup_theme', 'tu_add_comment_url_filter' );
function tu_add_comment_url_filter() {
add_filter( 'comment_form_default_fields', 'tu_disable_comment_url', 20 );
}
function tu_disable_comment_url($fields) {
unset($fields['url']);
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment