ResolvedChanging porfolio Slug

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27284
    Floppy78
    Participant

    Hi again, I’ve another issue to ask for. I’d like to change “portfolio” slug to “collections”. I know I should use functions.php in my child theme to redefine grosso_portfolio custom post tipe details but I’ll prefer to have some hints not to make mistakes. Thank a lot!

    #27375
    Althemist
    Keymaster

    Hello Flora,

    our lead developer Alex will step in to give you instructions.

    Regards,
    Dimitar

    #27393
    Alex
    Keymaster

    Hello Flora,

    Here is the exact code to put in your functions.php file in the child theme. I’ve modified all the labels from “portfolio” to “collection”, but double-check if they are what you want.

    remove_action('init', 'grosso_register_cpt_grosso_portfolio', 5);
    add_action('init', 'grosso_child_register_cpt_grosso_portfolio', 5);
    function grosso_child_register_cpt_grosso_portfolio() {
        $labels = array(
                'name' => esc_html__('Collections', 'grosso-plugin'),
                'singular_name' => esc_html__('Collection', 'grosso-plugin'),
                'add_new' => esc_html__('Add New', 'grosso-plugin'),
                'add_new_item' => esc_html__('Add New Collection', 'grosso-plugin'),
                'edit_item' => esc_html__('Edit Collection', 'grosso-plugin'),
                'new_item' => esc_html__('New Collection', 'grosso-plugin'),
                'view_item' => esc_html__('View Collection', 'grosso-plugin'),
                'search_items' => esc_html__('Search Collection', 'grosso-plugin'),
                'not_found' => esc_html__('No Collections found', 'grosso-plugin'),
                'not_found_in_trash' => esc_html__('No collection found in Trash', 'grosso-plugin'),
                'parent_item_colon' => esc_html__('Parent Collection:', 'grosso-plugin'),
                'menu_name' => esc_html__('Collections', 'grosso-plugin'),
        );
        $args = array(
                'labels' => $labels,
                'hierarchical' => false,
                'description' => 'Grosso portfolio post type',
                'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'revisions', 'page-attributes'),
                'taxonomies' => array('grosso_portfolio_category'),
                'public' => true,
                'show_ui' => true,
                'show_in_menu' => true,
                'show_in_nav_menus' => true,
                'publicly_queryable' => true,
                'exclude_from_search' => false,
                'has_archive' => true,
                'query_var' => true,
                'can_export' => true,
                'rewrite' => true,
                'capability_type' => 'page',
                'menu_icon' => 'dashicons-portfolio',
                'rewrite' => array(
                        'slug' => esc_html__('collection', 'grosso-plugin')
                )
        );
        register_post_type('grosso-portfolio', $args);
    }

    Regards,
    Alex

    #27503
    Floppy78
    Participant

    Thanks a lol for your help! It works perfectly! 🙂
    Have a good day!

    Flora

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in and have valid license to reply to this topic.

License required for any item belonging to this account
AlThemist

AlThemist

sales 17635, followers 745
Login and Registration Log in · Register