0

I have built a plugin that uses a custom post type and a single-.php file for a template. My issue is the custom post type template needs to take on the name of the post type and I need to change that. For example if my post type is called Movies then the template I call is single-movies.php. Also the permalink would be mydomain.com/movies.

I am providing a plugin options page that allows the user to change the name from Movies to say Films.

What is the best approach? Initially I thought about changing the custom post type name dynamically and renaming the file with the rename(). I kept getting an error "cURL wrapper does not support renaming"

I got to thinking . Is it easier to just rename the permalink with a mod rewrite and if so how would I do that. I'm trying to avoid a naming issue. If the user already has a permalink of Movies then I want them to be able to rename the post type to film or what ever they want.

The default of Movies will be stored as an option upon plugin activation and displayed in the options panel. If the user decides to change to "Films" the option is updated but how to I associate it to the custom post type template?

Any help on this is greatly appreciated. Phil

1 Answer 1

0

You can use the rewrite parameter of $args dynamically. Because the post type is registered every time wordpress loads (not just the first time register_post_type() loads), you can set any of the $args dynamically so long as the $post_type slug stays the same.

See the codex documentation on register_post_type() for a list of the arguments you can modify.

1
  • Oh man! The one place I didn't look. I wasted yesterday. Should have came here first! Thanks
    – krazymatty
    Commented Mar 2, 2012 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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