This topic has 3 replies, 2 voices, and was last updated 9 years by Radu.

  • Author
  • #125874
     meet
    Participant

    Hi Radu,

    I need to change the label of a post -type, from ‘Portfolio’ to ‘My Work’.

    I do not want to make any changes with slug as I have attached portfolios already and they are super custom code and dynamic.

    I do not want to do any kind of changes with the core code of the theme. Want to manage it through functions.php of my child theme.

    Please help me with this.

    #125935
     Radu
    Moderator
    Not marked as solution
    #126682
     meet
    Participant
    Hey Radu, I did not use that plugin. I got some code and through that I changed the labels of post types.
    add_action( 'wp_loaded', 'renamePostTypeLabel', 20 );
    function renamePostTypeLabel()
    {
        global $wp_post_types;
        $p = 'portfolio';
         
        // 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 ) ) return;
    
        /*Portfolio*/
        $wp_post_types[ $p ]->labels->name               = 'WikiPOP';
        $wp_post_types[ $p ]->labels->singular_name      = 'WikiPOP';
        $wp_post_types[ $p ]->labels->add_new            = 'Add WikiPOP';
        $wp_post_types[ $p ]->labels->add_new_item       = 'Add new WikiPOP';
        $wp_post_types[ $p ]->labels->all_items          = 'All WikiPOP';
        $wp_post_types[ $p ]->labels->edit_item          = 'Edit WikiPOP';
        $wp_post_types[ $p ]->labels->name_admin_bar     = 'WikiPOP';
        $wp_post_types[ $p ]->labels->menu_name          = 'WikiPOP';
        $wp_post_types[ $p ]->labels->new_item           = 'New WikiPOP';
        $wp_post_types[ $p ]->labels->not_found          = 'No WikiPOP found';
        $wp_post_types[ $p ]->labels->not_found_in_trash = 'No WikiPOP found in trash';
        $wp_post_types[ $p ]->labels->search_items       = 'Search WikiPOP';
        $wp_post_types[ $p ]->labels->view_item          = 'View WikiPOP';
    }
    #126754
     Radu
    Moderator
    Not marked as solution
Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?