Question

I was wondering if there is a way to edit the default field labels on a custom post, for example instead of the author field saying "author" have it say "keynote speaker" I found one solution listed below, but this obviously edits it across the entire backend.

add_filter( 'gettext', 'change_author_to_keynote' );
add_filter( 'ngettext', 'change_author_to_keynote' );

function change_author_to_keynote( $translated ) 
{  
    $translated = str_replace( 'Author', 'Keynote Speaker', $translated );
    $translated = str_replace( 'author', 'keynote speaker', $translated );
    return $translated;
}

Thanks in advance,

Pete

Was it helpful?

Solution

you can use:

add_filter('gettext','custom_author_lable');
function custom_author_lable( $input ) {
    global $post_type;
    if( is_admin() && 'your_post_type' == $post_type )
        if ('Author' == $input || 'author' == $input)
                 return 'Keynote Speaker';      
    return $input; 
} 

just replace your_post_type.

OTHER TIPS

I think your two filters are possible for parse strings and replace it.

Hint: You can also see an example on githup, on a free plugin for language strings: https://github.com/toscho/Germanix-WordPress-Plugin/blob/master/germanix_translate.php

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top