I have a WordPress site with a blog on /blog/, and I also have a custom post type, which for now, we can call “recipes”. How can I get a unique permalink/slug for each post type?

I want to achieve:

http://domain.com/blog/post-name-here <- Standard "post" post_type
http://domain.com/recipes/post-name-here <- Only "recipes" post_type

Settings>Permalinks does not help me - I can either set

http://domain.com/blog/post-name-here
http://domain.com/blog/recipes/post-name-here
-or-
http://domain.com/post-name-here
http://domain.com/recipes/post-name-here

Why does it seem so rigid! Here is my custom post type code in functions.php (with some of the fat trimmed):

add_action( 'init', 'create_posttype' );
function create_posttype() {
    register_post_type( 'recipe',
        array(
            'labels' => array(
                'name' => __( 'Recipes' ),
                'singular_name' => __( 'Recipe' ),
            ),
            'public' => true,
            'has_archive' => false,
            'menu_position' => 5,
            'rewrite' => array('slug' => 'recipes')
        )
    );
}

If anyone could provide a way to have either:

  • A page parent for the standard ‘post’ post_type (considering I can set rewrite param in code above)
  • Set permanlink structure in Settings>Permalinks to /blog/%postname%/ without the “recipe” post_type adopting this

It would be greatly appreciated!

Read more here: Set permalink just for normal posts in WordPress, excluding custom post types


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , , , ,

Wordpress related questions and answers: