X

Comment supprimer le champ URL du formulaire de commentaires ?

Snippets by IsItWP

Vous cherchez un moyen de supprimer le champ URL du formulaire de commentaires ? Ce snippet vous permet de supprimer facilement le champ URL / site web du formulaire de commentaires dans WordPress.

Instructions:

Tout ce que vous avez à faire est d’ajouter ce code dans le fichier functions.php de votre thème ou dans un plugin spécifique à votre site:

add_filter('comment_form_default_fields', 'unset_url_field');
function unset_url_field($fields){
    if(isset($fields['url']))
       unset($fields['url']);
       return $fields;
}

Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez vous référer à notre guide sur comment copier/coller correctement des extraits de code dans WordPress, afin de ne pas casser accidentellement votre site.

Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : 9 meilleurs outils de référencement pour augmenter le trafic de votre site Web, RAPIDEMENT !

Commentaires   laisser une réponse

  1. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot.

  2. Gave me the white screen of death.

    1. This is more likely an issue with the functions.php file rather than the snippet. I would check the functions.php file to make sure,

  3. How To Remove The URL Field From WordPress Comments - WPMU.org mars 26, 2013 à 5:17 pm

    […] a quick snippet I found the other day while browsing WPSNIPP.com. You can add the code below to your theme’s functions.php file or create a quick […]

  4. try it like this but not working if(have_some_suggestion){
    for_functions{
    ID);

    function unset_url_field($page_id ){

    if(isset($page_id [‘url’]))

    unset($page_id [‘url’]);

    return $page_id ;

    }

    }
    ————————————————————————–*/–>
    }
    }

  5. GoWebBaby WorDPress Firm août 17, 2012 à 7:40 am

    Why to remove url field from the comment form, it encourage commenter to comment instead of it better to assign no follow link attribute.

    1. This snippet is more for people that are working on a theme, removing the field could be used for product reviews or if they created a support tickets theme that does not require a url field.

      1. // I just want to unset from comment form the Home page

        add_filter(‘comment_form_default_fields’, ‘unset_url_field’);

        if($fields = is_home() || is_front_page() {

        function unset_url_field($fields){

        if(isset($fields[‘url’]))

        unset($fields[‘url’]);

        return $fields;

        }

        }

    2. I’m sure you’ve seen the URL field on the comments form. It’s there for a reason, but it’s also a pain in the butt.
      I’m going to show you how to remove the URL field from the comments form and replace it with a text field.
      The URL field is there for a reason. If you’re not familiar with it, it’s there so that you can link to another page on your site.
      For example, let’s say you’re writing a blog post and you want to link to another post on your site. You can do that with the URL field.
      You can also use the URL field to link to an external website. For example, if you’re selling a product on your site, you can link to a product page on another site.
      The problem with the URL field is that it’s a pain to use. You have to enter the URL manually, and it’s not very user-friendly.
      If you’re going to use the URL field, you need to make sure that you’re linking to a page that’s on your site. If you link to a page on another site, it won’t work.
      You’ll also want to make sure that the URL you’re entering is a valid URL. For example, you can’t link to a page that doesn’t exist. You can’t use a URL that’s too long or too short.
      You should also make sure that you don’t have any special characters in the URL. You can use special characters in a URL, but if you do, you’ll need to encode them.

Ajouter un commentaire

Nous sommes heureux que vous ayez choisi de laisser un commentaire. N'oubliez pas que tous les commentaires sont modérés conformément à notre privacy policy, et que tous les liens sont en nofollow. N'utilisez PAS de mots-clés dans le champ du nom. Engageons une conversation personnelle et constructive.

WordPress Launch Checklist

L'ultime liste de contrôle pour le lancement de WordPress

Nous avons rassemblé tous les éléments essentiels de la liste de contrôle pour le lancement de votre prochain site Web WordPress dans un ebook pratique.
Oui, envoyez-moi le gratuit !