How to Edit a Slug/Link/Permalink of a Custom Post Type in WordPress

If you need to test drive WordPress, Try it now!

Sharing is caring!

So you’ve created a cool custom post type in WordPress but can’t find a way to edit its slug/link/permalink?

Editing the slug is not that obvious for a custom post types. We know. WordPress shows the default/classic WordPress editor and not the block editor for custom post types.

So you’ve added a custom post type and want to change the post type’s slug you need to do the following.

Go to Screen Options (close to top right corner).

After you click that make sure that Slug checkbox is checked. Then click on Screen Options again to hide it.

After you’ve done with this you need to scroll down a little to get to the meta boxes.

There you should be able to edit the slug/link of your custom post type.

You can create a custom post type using register_post_type() function. It depends on your skill level you can use a plugin to create the custom post type for you.

Here’s an example php code that shows you how to create/register the custom post type in WordPress.

$labels = array(
			'name'                  => _x( 'Projects', 'Post Type General Name', 'wpgigs' ),
			'singular_name'         => _x( 'Project', 'Post Type Singular Name', 'wpgigs' ),
			// ... Add other labels as needed

		$cpt_rewrite_args = [
		    'slug' => 'project',

		$args = array(
			'label'                 => __( 'Project', 'wpgigs' ),
			'labels'                => $labels,
			'supports'              => array( 'title', 'editor', 'page-attributes', 'author', 'thumbnail', 'excerpt', ), // 'comments'
			'public'                => true,
			'show_in_menu'          => true,
			'menu_position'         => 2,
			'menu_icon'             => 'dashicons-admin-post',
			'show_in_admin_bar'     => true,
			'show_in_nav_menus'     => true,
			'can_export'            => true,
			'has_archive'           => true,
			'exclude_from_search'   => false,
			'publicly_queryable'    => true,
			'rewrite'               => $cpt_rewrite_args,
			'capability_type'       => 'post',

		register_post_type( 'wpg_project', $args );

that code should be in a function that gets executed during the init action otherwise you may get an error.

add_action( 'init', array( $this, 'register_project_post_type' ) );

Notes: After you edit the slug WordPress will still have the final say in terms of what the final permalink will look like. It will ensure that the link is unique by appending some numbers at the end if it’s not unique enough.

Custom post types in WordPress are essential for adding various types of content beyond the default posts and pages. They allow for more organized and efficient content management, tailored to specific needs of a website. For example:

  1. Portfolio: Ideal for artists, designers, and photographers to showcase their work.
  2. Events: For managing event details, dates, locations, and more, useful for businesses or communities organizing regular events.
  3. Products: E-commerce sites use custom post types to manage and display products, integrating with shopping cart and payment functionalities.
  4. Testimonials: A dedicated post type for displaying customer feedback, enhancing credibility and trustworthiness of a business.
  5. FAQs: Useful for information-heavy sites, where questions and answers can be managed separately from blogs or articles.

These examples demonstrate the versatility of custom post types in enhancing the functionality and organization of a WordPress website, making it a powerful tool for web developers and site managers.

Sharing is caring!

If you need to test drive WordPress, Try it now!

Leave a Comment

Your email address will not be published. Required fields are marked *