I hate putting things into the functions.php file and therefore wanted to hook into a pre-existing WP-hook to register/configure my custom post-types (and taxonomies). Somewhere I was reading that “template-redirect” would be a good one but it appear that that hook isn’t fired when you’re on the admin pages and therefore is fairly useless.
Any help would be appreciated.
You can use
init
hook.An example of registering a post type called “book”.
Reference: Codex.
I was reviewing my open questions and it reminded me that I hadn’t closed this one out. Marty’s answer was helpful but really pointed to a different solution path. In retrospect, I’m not sure what hook I had tried but the kind of obvious one is “init” and I’m using that now and it works.
Here’s my flow:
When the ‘admin’ event is fired my plugin then this fires off the following function:
This approach gives me a completely decoupled approach which means I can enable the “custom_types” plugin and I now have the ‘capability’ installed. Then I create a configuration plugin that hooks into the events that the capability has added.
Hope this helps.
You could use an include file within functions.php to include all your custom work.
I’ve created a very simple page to create your custom post types,
you input the options you want for the custom field and it spits out the code needed in order to generate it in wordpress..
its located here: http://martin-gardner.co.uk/wordpress-custom-post-type-generator/
for example:
Read more on custom post types and the register_post_type @
http://codex.wordpress.org/Function_Reference/register_post_type
hope that helps a little 😉
Marty