Understanding Naming of Custom Post Types
-
I tried to post this in the advanced area but it appears to be closed. This isn’t really about any particular plugin.
I’m making a plugin that creates a couple custom post types and no matter how many times I read the codex, I can’t seem to come up with a good system for naming custom post types.
I realize that once a custom post type is created, it’s archive page with the same name is also created (unless changed by the rewrite option or unless the archives option is false).
I’m not asking about how to set anything or how to customize the register_post_type function.
What I’m asking about is how best to avoid naming conflicts with pages when naming these custom post types.
For example, if I create a custom post type named “team” then the slug becomes “team” and the archive lives at somesite.com/team/.
What if a page named “team” already exists? Well, I know what will happen and it’s not good. What if someone creates a page called “team” later?
I realize the codex suggests we namespace these custom post types. However, when you’re the first in line,and these custom post types pretty much ARE the site, can’t one claim these names before any other plugin? WordPress does it with “post” “revision” etc. Why can’t I if these are major parts of this site?
But, that’s besides the point and I’m just trying to avoid reading anyone complaining that I should just namespace my custom post types and be done with it.
Or, its it possible to name the custom post type something like namespace_team and then NOT have to ever see, or have anyone else in the admin see, that ugly thing again?
Another good example is naming a custom post type “testimonial”. I have to add the rewrite slug for “testimonials” or the archive page is illogical. But, then it conflicts with the page named “testimonials”, where the testimonials actually reside.
Is it best to avoid using pages for display of custom post types? I could use the templates like single-posttype.php and archive-posttype.php. But, the site I’m working with already has everything set up on pages using Essentail Grid for display.
Can anyone shed some light on the best practices for dealing with custom post type names and pages of the same name? I’ve been searching online for days. There’s some info out there but just coding examples, no discussion of best practices. It seems like nobody out there understands this stuff enough to explain it. Hopefully someone here does. But, I searched this forum and no luck.
Although the search results were mostly for the codex and not this forum. odd. Am I searching wrong?
- The topic ‘Understanding Naming of Custom Post Types’ is closed to new replies.