---
title: Change the slug for custom post types?
description: "To change the slug for the custom post type, you need to use this snippet below in your functions.php file, which is available under the child theme. ``` /* CHANGE SLUGS OF CUSTOM POST TYPES */ /** * @param $args…"
url: "https://www.codeixer.com/docs/how-to-change-the-slug-for-custom-post-types/"
updated: "2024-04-22"
category: Medixer – Medical WordPress Theme
---

# Change the slug for custom post types?

To change the slug for the custom post type, you need to use this snippet below in your functions.php file, which is available under the child theme.

```
/*
CHANGE SLUGS OF CUSTOM POST TYPES
 */

/**
 * @param $args
 * @param $post_type
 * @return mixed
 */
function medixer_post_types_slug( $args, $post_type ) {

	/*item post type slug*/
	if ( 'fw-portfolio' === $post_type ) {
		$args['rewrite']['slug'] = 'portfolio';
	}

	return $args;
}
add_filter( 'register_post_type_args', 'medixer_post_types_slug', 10, 2 );
```

Remember to save the permalinks again to prevent 404 error after adding this code.

![](https://codeixer.com/wp-content/uploads/2023/04/CleanShot-2023-04-08-at-03.16.38-1024x428.png)
