0

In my wp site there is a custom post type movies.i used cpt plugin to create it. so if i have a post with title zootopia it's url appear as ,

http://localhost/mysite/movie/zootopia/

however i want to change this url to

http://localhost/mysite/parent/movie/zootopia/.so when i click view post i want this url to appear in address bar

so i want to replace url /movie/ to /parent/movie/

i tried with add_rewrite_rule function

add_action('init', 'add_actor_url');
function add_actor_url()
{
    add_rewrite_rule( '^movie/([^/]*)', 'parent/movie/$matches[1]', 'top' );
    flush_rewrite_rules();
}

but this doesn't work.it doesn't replace url http://localhost/mysite/movie/zootopia/ to http://localhost/mysite/parent/movie/zootopia/

is it really possible.if it's not then is there any other way to do that ?

1 Answer 1

2

You just need to set the slug to literally parent/movie. If you're doing it in code you set the 'rewrite' => 'slug' argument to 'parent/movie'. If it's in a plugin it would depend on the plugin, but there should be a setting for "slug" or similar.

2
  • but my post type is movie.so how can i set slug as parent/movie custom post type plugin support slug changes but without /
    – Fast Snail
    Oct 28, 2017 at 7:05
  • Then your issue is a support issue with the plugin developers. / is supported in code, so the plugin is over-aggressively sanitising the field. Note that the name is not the same as the slug. Oct 28, 2017 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.