• Hello,
    I’ve a theme with a plugin provided by theme developer for manage portfolios section.
    This plugin create a custom post type with this code:

    //Portfolio post type
                        register_post_type('wyde_portfolio',
                                    array(
                                            'labels' => array(
                                                        'name'                      => __( 'Portfolios', 'Wyde' ),
                                                        'singular_name' => __( 'Portfolio', 'Wyde' ),
                                        'add_new' => __('Add New', 'Wyde' ),
                                        'add_new_item' => __('Add New Portfolio', 'Wyde'),
                                        'edit_item' => __('Edit Portfolio', 'Wyde'),
                                        'new_item' => __('New Portfolio', 'Wyde'),
                                        'view_item' => __('View Portfolios', 'Wyde'),
                                        'menu_name' => __('Portfolios', 'Wyde')
                                            ),
                                            'public' => true,
                                            'has_archive' => false,
                                            'rewrite' => array(
                                                        'slug' => sanitize_title( $portfolio_slug ),
                                            ),
                                            'supports' => array( 'title', 'editor', 'thumbnail'),
                                            'can_export' => true,
                                'menu_icon' => 'dashicons-portfolio'
                                    )
                            );

    I’d like to add the option with_front => false in rewrite, in order to put all the permalink in the root of my site. So I had to change the rewrite with:

    'rewrite' => array(
           'slug' => sanitize_title( $portfolio_slug ),
           with_front => false,
    ),

    I don’t want to change the plugin file cause I will loose the change at every updates.
    Is it possible to add that option later, for example in function.php of my child theme?

    Reading the register_post_type documentation it seems that is possible modify the post type (A function for creating or modifying a post type).
    I’ve tried to simply add this to my function.php:

    register_post_type('wyde_portfolio',
                                    array(
                                            'rewrite' => array(
                                                        'slug' => sanitize_title( $portfolio_slug ),
                                                         with_front => false,
                                            ),
    						)
                            );

    but it doesn’t work.

    I’ve tried also to redeclare all the params in register_post_type but it still doesn’t work.

    Do you have any suggestion on how I can solve it?

    Thanks a lot in advance

  • The topic ‘Modify parameters of register_post_type’ is closed to new replies.