Vous cherchez un moyen de remplacer des mots dans l’administration de WordPress ? Ce snippet utilise les filtres gettext
et ngetext
pour remplacer un tableau de mots dans l’administration de WordPress.
Instructions:
- Ajoutez ce code au fichier functions.php de votre thème ou dans un plugin spécifique à votre site.
- Modifiez le tableau
$words
. Ajoutez les mots que vous souhaitez remplacer aux clés et le texte de remplacement aux valeurs des clés.
add_filter( 'gettext', 'wps_translate_words_array' ); add_filter( 'ngettext', 'wps_translate_words_array' ); function wps_translate_words_array( $translated ) { $words = array( // 'word to translate' = > 'translation' 'Posts' => 'Article', 'Post' => 'Articles', 'Pages' => 'Stuffing', 'Media' => 'Upload Images', 'Links' => 'Blog Roll', ); $translated = str_ireplace( array_keys($words), $words, $translated ); return $translated; }
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez consulter notre guide sur la manière de copier/coller correctement des extraits de code dans WordPress, afin de ne pas endommager accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : Comment créer correctement une page de connexion personnalisée sur WordPress (étape par étape).
Perfect! The only place it didn’t change was the left-hand dashboard navigation menu. However, I found another article (from another site) that fixes that issue. Thank you!
it didnt work for me
Hi Andrew,
Which file did you paste the code into?
Thanks for sharing the tips. Simple yet powerful. Wonder will it clash with the custom plugin. but will try this out.
Also besides from wanting to change 7308064.jpg as post title to anpther words can you please help on telling me how to show images while in edit post mode,
Note i am a newbie but would like to learn
Thanks
Hi
Thanks for the great trick wondering if could shed light on the below
what if i have 7308064.jpg as title how do i go about replacing this to whatever i want
can i add a shortened link followed by some keywords.
[…] from WPSnipp.com (Update: added “if is_admin” […]
Wow! i didn’t about this before. sometimes for certain scenarios it would be great to rename some WP items, like you did to Posts -> Articles.
Keep up the great work 😉
Hi Wesam, glad you like the snippet, great if you have a few things within the wordpress admin you want to change. Enjoy the wpsnipp 🙂