Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Oh man! The one place I didn't look. I wasted yesterday. Should have came here first! Thanks –  krazymatty Mar 2 '12 at 18:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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