Search code examples
wordpress.htaccessurlcustom-post-typepermalinks

Show different URL in address bar


I have a custom post with post-type "podcast" and now my podcast post single URL is http://localhost/sitename/blog/podcast/post-name. But I want to show post-type "podcast" URL like: http://localhost/sitename/test/podcast/post-name.

Currently site permalink is set to custom structure with /blog/%postname%. So blog is showing with each custom post type. And I want to keep permalink structure same but blog will not show in "podcast" post URL.

I have already created a new file for single podcast with copied single.php and changed name to single-podcast.php. It's working fine with http://localhost/xyz/blog/podcast/post-name but I want to show different name in URL.

Can you please suggest a solution for this?


Solution

  • Have you tried rewrite options? https://codex.wordpress.org/Function_Reference/register_post_type#Parameters

    Example:

    [
        'rewrite'   => [
            'slug'         => 'your/custom/post/slug/here',
            'with_front'   => false,
        ],
    ]