• Resolved uptree

    (@uptree)


    Hello all,

    I’m hoping someone can help me apply a filter to the categories description text in the admin. It currently reads:

    Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.

    I am trying to edit this to say something much more generic, as I’m working on a project for a non-profit that is very professional in nature. I have searched for filters and have tried creating something of my own, but with no success.

    The default code currently resides in wp-admin/edit-tags.php and wp-admin/edit-tag-form.php.

    My apologies if this quite simple – I’m not great with PHP.

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The default code currently resides in wp-admin/edit-tags.php and wp-admin/edit-tag-form.php.

    Even if you altered it, whatever changes you made would be eliminated with the next WordPress update as these are core files.

    Thread Starter uptree

    (@uptree)

    Yeah, I’m hoping someone can help me figure out how to filter it so the changes won’t be overwritten when WP updates.

    based on https://blog.ftwr.co.uk/archives/2010/01/02/mangling-strings-for-fun-and-profit/

    example code for functions.php of your (child) theme:

    class Special_Text_Wrangler {
    function admin_category_hierarchy_intro($translation, $text, $domain) {
    $translations = &get_translations_for_domain( $domain );
    if ( $text == 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ) {
    return $translations->translate( 'category parent/child intro - something more generic' );
    }
    return $translation;
    }
    }
    add_filter('gettext', array('Special_Text_Wrangler', 'admin_category_hierarchy_intro'), 10, 4);
    Thread Starter uptree

    (@uptree)

    Works perfectly, Michael! Thank you so much for taking the time to help.

    Thread Starter uptree

    (@uptree)

    I just wanted to add that I removed the class and wrapped the remaining function in a conditional to (1) test if we’re in the admin and (2) test if we’re on the admin page that actually has this text by testing if the $current_screen’s taxonomy matches the string ‘category’:

    global $current_screen;
    function current_admin_screen_category( $current_screen ) {
    $tax = $current_screen->taxonomy;
    if ( is_admin() && ('category' == $tax){
        // function from Michael's answer goes here
    }
    add_action( 'current_screen', 'current_admin_screen_category' );
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Modify Categories description text in wp-admin’ is closed to new replies.