How to do different Custom Post Type Permalinks?

#923786
  • Suri Liu
    Rank Math free

    Is there anyway to configure different permalink structure to different custom post type with rankmath?

    I have a custom post type named Directory, and I am using default post for publishing blogs. i want to set blog permalink structure to : /blog/%category%/%postname%, and set Directory permalink structure to : /directory/%category%/%postname%

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello,

    We apologize for the issue you are facing. To configure different permalink structures for different custom post types in WordPress using Rank Math, you can follow these steps:

    1. Navigate to Permalinks: Go to WordPress Settings → Permalinks.
      Go to Permalinks

    2. Set Blog Permalink Structure: For your blog posts, you can set the permalink structure to /blog/%category%/%postname%. This can be done by selecting the Custom Structure option and entering the desired structure.
      Permalink Settings

    3. Set Directory Permalink Structure: For your custom post type named Directory, you will need to register the custom post type with a specific rewrite rule. This is typically done in your theme’s functions.php file or a custom plugin. Here’s an example of how you might register it:

      function create_directory_post_type() {
         register_post_type('directory', array(
             'labels' => array(
                 'name' => __('Directories'),
                 'singular_name' => __('Directory')
             ),
             'public' => true,
             'has_archive' => true,
             'rewrite' => array('slug' => 'directory/%category%/%postname%'),
             'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments'),
         ));
      }
      add_action('init', 'create_directory_post_type');

      This code snippet registers a custom post type called Directory with the desired permalink structure.

    4. Flush Rewrite Rules: After making changes to permalinks or registering a new custom post type, it’s important to flush the rewrite rules. You can do this by simply visiting the Permalinks settings page and clicking Save Changes without making any changes.

    By following these steps, you should be able to set different permalink structures for your blog posts and the Directory custom post type. If you have any further questions or need assistance, please reply to this ticket, and a human agent from the Rank Math Support team will assist you further!

    Sources:
    WordPress Permalink Structure & Changing Individual URLs » Rank Math

    This is an automated reply from Rank Math Support Bot. Your ticket has been assigned to a human agent and we will get back to you shortly.

    Hello,

    Thank you for contacting us and bringing your concern to our attention.

    Unfortunately, Rank Math doesn’t have any option to create a permalink structure.

    However, you can use any external plugin like Permalink Manager to create different permalink structures for different post types.

    Hope that helps and please don’t hesitate to let us know if you have any other questions.

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

You must be logged in to reply to this ticket.