X

Comment modifier le texte de l’option “Définir l’image vedette” dans l’administration de WordPress

Snippets by IsItWP

Vous souhaitez modifier le texte “Définir l’image principale” dans l’administration de WordPress ? Ce snippet changera le texte “Définir l’image en vedette” en “Définir l’image par défaut” ou tout autre texte que vous souhaitez.

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. Modifiez éventuellement le texte de remplacement à la ligne 2.

function custom_admin_post_thumbnail_html( $content ) {
    return $content = str_replace( __( 'Set featured image' ), __( 'Set default image' ), $content); 
}
add_filter( 'admin_post_thumbnail_html', 'custom_admin_post_thumbnail_html' );

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 : 6 meilleurs plugins d’optimisation d’images pour WordPress (comparés)

Commentaires   laisser une réponse

  1. Dmitrii Kustov août 1, 2020 à 2:02 am

    Any idea how to do this for the Gutenberg?

  2. Does not work with Gutenberg

    1. Yes, this is for the classic editor. Editing the text in the new Block editor requires different code.

    2. i love wordpress from the bottom of my heart I love it.

  3. Pramod Kharade mars 9, 2015 à 1:36 am

    How to added meta labels to featured images in wordpress using custom type
    ?

  4. How could I change the “Featured Image” title of the metabox?

  5. Hey, any idea on how you could limit this to particular custom post types such as “Events” and “Locations” while leaving the default text for standard wordpress pages and posts?

    1. if ($_GET[‘post_type’] == ‘Events’ || $_GET[‘post_type’] == ‘Locations’) {

      #your code….

      }

  6. great site

  7. Never forget your Featured Image Dimensions - WPMU.org août 15, 2012 à 10:00 am

    […] from WPSnipp.com – more Featured Image […]

  8. Nice site. I’ve a little problem. When i click on the Set Featured Image it shows the media library and here there are three options saying “Insert into Post” , “set as featured imaged” and “Cancel” which is very confusing I dont want “Insert into Post” appear here. Any ideas, how i can remove insert into post also i dont want Alignment row. 

  9. New look, same great content (September 2011 website update) | Best Owasso Realtor Cliff Paulick septembre 10, 2011 à 12:30 pm

    […] Renamed “Set featured image” to “Set featured image (315w x 190h)” using WPSnipp’s function. […]

  10. Almost exactly what I want. Great site! Your solution works until a featured image is set. Then it gets replaced with “Remove featured image”. I’m sure you could replace that text too, but I want the metabox’s heading to be “Featured Image (315w x 190h)” instead of “Featured Image”. Thanks.

    1. Hi Cliff sorry about the delay did not see your comment, anyway you could do something like this.

      add_filter(  ‘gettext’,  ‘change_featuredimage_txt’  );
      add_filter(  ‘ngettext’,  ‘change_featuredimage_txt’  );
      function change_featuredimage_txt( $translated ) {
           $translated = str_ireplace(  ‘Featured Image’,  ‘Slideshow Image’,  $translated );
           return $translated;
      }

      1. Turns out you only need the 2nd one:
        // 1function custom_admin_post_thumbnail_html( $content ) {    return $content = str_replace( __( ‘Set featured image’ ), __( ‘Set featured image (315w x 190h)’ ), $content);}add_filter( ‘admin_post_thumbnail_html’, ‘custom_admin_post_thumbnail_html’ );
        // 2add_filter(  ‘gettext’,  ‘change_featuredimage_txt’  );add_filter(  ‘ngettext’,  ‘change_featuredimage_txt’  );function change_featuredimage_txt( $translated ) {     $translated = str_ireplace(  ‘Featured Image’,  ‘Featured image (315w x 190h)’,  $translated );     return $translated;}
        By having both of those codes in functions.php, the header says “Featured image (315w x 190h)” (which is what I want), but then the link to set the image reads “Set Featured image (315w x 190h) (315w x 190h)”. So I took out the 1st code and just have the 2nd and it works just like I wanted.
        The header reads the same as before, but the link text reads “Set Featured image (315w x 190h)”.
        Thanks! 🙂

        1. Cool glad you got everything working.

      2.  Fantastic little bit of code that one!! Everything I needed and nothing more. Thanks for posting it.

      3. Thanks for posting very helpful

  11. Davey IJzermans août 2, 2011 à 1:39 pm

    Thank you very much! I find WordPress lacks in a nice overview of where you can find everything. This site’s a great example!

    1. Hi Davey, Glad I could help and enjoy the rest of the site.

  12. Great site

    1. Thanks glad you like the website,

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 !