Change portfolio slug

  • Posted in : TheBlogger
  • thame
    Participant

    Hi, I’d like to change the portfolio slug from ‘portfolio’ to something else.

    Mehmet S.
    Keymaster

    Hi,

    – Go to Appearance > Theme File Editor,
    – Open functions.php file (Theme Functions),
    – Add the below code to the end of the file.
    – Only change portfolio word in the line: ‘slug’ => ‘portfolio’,
    – Save changes.

    function theme_update_portfolio_slug($args, $post_type)
    {
    	if ('portfolio' === $post_type)
    	{
    		$new_args = array(
    			'rewrite' => array(
    				'slug'       => 'portfolio',
    				'with_front' => false
    			)
    		);
    		
    		return array_merge($args, $new_args);
    	}
    	
    	return $args;
    }
    
    add_filter('register_post_type_args', 'theme_update_portfolio_slug', 10, 2);
    

    – Go to your Settings > Permalinks page, and refresh your permalink settings.

    Thanks

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

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

License required for the following item
Login and Registration Log in · Register