• Resolved plusless

    (@plusless)


    Hi all,

    I registered a custom taxonomy under a custom post type, but would like to change the default description below the input fields in the Taxonomy page to something for more fitting for the purpose of the custom taxonomy. Are there any default functions to do this? If not, is there another clever way to do this?

    WordPress Taxonomy input Description

    Thanks in advance,

    Wessel

    • This topic was modified 9 years, 3 months ago by plusless.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Those strings are run through translation functions (as in __() _e() _x() etc.). This means you can use the “gettext” filter to alter it in ways besides translations. Have your callback check for a match. When it occurs, return the alternative value. Your callback needs to be as efficient as possible. gettext() gets called many times on a typical page.

    Thread Starter plusless

    (@plusless)

    Thanks @bcworkz for your help, I got it to work:

    add_filter('gettext', 'changeTaxonomyLabels');
    function changeTaxonomyLabels($translated_text) {
    	global $taxonomy;
    
    	if (is_admin() && $taxonomy == 'artists') {
    		switch ($translated_text) {
    			case 'The description is not prominent by default; however, some themes may show it.':
    				$translated_text = __('A short description about the artist.');
    				break;
    		}
    	} return $translated_text;
    }

    How to function works:
    First off we get the global $taxonomy variable, so we can check it later. Then we make sure that the current user is an admin, and that the current page is one of our taxonomy (which is called artists). We replace the default text (the case) with our custom text (‘A short description about the artist’) by changing the $translated_text variable. And finally, return the updated variable.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Change default Taxonomy input Description’ is closed to new replies.