Change the slug for portfolio post type


#1

Are we able to do this yet?

I believe you could do this with Jupiter Legacy in the theme options. I don’t want my URLs to say /portfolio/. I did check the customiser portfolio tab but couldn’t see anything there?

Be good to know if this is possible in Jupiter beta 2.


#2

Any reply on this at all?


#3

I would like to be able to do this as well. Is it possible with the functions.php in a child theme by chance?


#4

Having the same problem. I need to have the default post as /blog and /portfolio as /news but it ends up in /blog/news when it’s a portfolio’s post.

We just need the function for rewriting the portfolio slug and set ‘with_front’ to false for removing the “blog/” from the portfolios.

Please reply.
Thank you.


#5

To change the Portfolio slug, you can use the below code at the bottom of functions.php file in child theme.

add_filter( 'register_post_type_args', 'wpse247328_register_post_type_args', 10, 2 );
function wpse247328_register_post_type_args( $args, $post_type ) {

	if ( 'portfolio' === $post_type ) {
		$args['rewrite']['slug'] = 'projects';
	}

	return $args;
}

Then, go to WP Dashboard -> Settings -> Permalinks and save changes without editing anything. This is to refresh the permalinks so that the new changes take place.


Custom portfolio page
#6

Hello, is it possible to use that code also without child theme?