Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm developing a child theme of a premium template, this comes with a custom post type with the label name of "Projects" but I'd like to change it to something else, I know that if I go to the functions.php file of the main theme I can change it easily but I'd like to change it from my child theme so I don't have to edit any of the original files, is it possible?

Thanks in advance!

share|improve this question

1 Answer 1

up vote 8 down vote accepted

There is a global array $wp_post_types. You can change $wp_post_types[$post_type]->labels after the parent theme has set the CPT.

So … if the parent theme registers the CPT on 'init' like this:

add_action( 'init', 'register_my_cpt', 12 );

Then you need a later priority:

add_action( 'init', 'change_cpt_labels', 13 );

… or a later hook. I would use wp_loaded:

add_action( 'wp_loaded', 'change_cpt_labels' );

Example for custom post type place changed to location

add_action( 'wp_loaded', 'wpse_19240_change_place_labels', 20 );

function wpse_19240_change_place_labels()
    global $wp_post_types;
    $p = 'place';

    // Someone has changed this post type, always check for that!
    if ( empty ( $wp_post_types[ $p ] )
        or ! is_object( $wp_post_types[ $p ] )
        or empty ( $wp_post_types[ $p ]->labels )

    // see get_post_type_labels()
    $wp_post_types[ $p ]->labels->name               = 'Locations';
    $wp_post_types[ $p ]->labels->singular_name      = 'Location';
    $wp_post_types[ $p ]->labels->add_new            = 'Add location';
    $wp_post_types[ $p ]->labels->add_new_item       = 'Add new location';
    $wp_post_types[ $p ]->labels->all_items          = 'All locations';
    $wp_post_types[ $p ]->labels->edit_item          = 'Edit location';
    $wp_post_types[ $p ]->labels->name_admin_bar     = 'Location';
    $wp_post_types[ $p ]->labels->menu_name          = 'Location';
    $wp_post_types[ $p ]->labels->new_item           = 'New location';
    $wp_post_types[ $p ]->labels->not_found          = 'No locations found';
    $wp_post_types[ $p ]->labels->not_found_in_trash = 'No locations found in trash';
    $wp_post_types[ $p ]->labels->search_items       = 'Search locations';
    $wp_post_types[ $p ]->labels->view_item          = 'View location';
share|improve this answer
you beat me to it toscho. btw how do you pronounce your username. – xLRDxREVENGEx Jun 5 '11 at 4:45
@xLRDxREVENGEx I asked Google to make an audio file for me, and here you go. – toscho Jun 5 '11 at 5:03
That is what i thought it would be. – xLRDxREVENGEx Jun 5 '11 at 5:05
great that worked nicely thanks – javiervd Jun 6 '11 at 13:10
@JeremyMiller See my update. – toscho Apr 19 '13 at 7:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.