Would too many WordPress hooks cause a performance hit?

I’m working on a boilerplate for custom post types and custom taxonomies and I’ve run into a dilemma. I like the organization of having each of my custom post types in their own included php file, but since I’d have an add_action('init', 'POSTTYPE_NAME_register', 0); in each of those, would there be a significant performance hit from having multiple hooks in init as opposed to consolidating them into a single function?

Related posts

Leave a Reply

2 comments

  1. No. The biggest slowdown in your scheme would be the accessing of the multiple files. Unless you’re loading 1000s of included files this way, it’s probably not an issue. If you have a reason to have each CPT in it’s own file, do it.

  2. I’d agree that this would not be a performance problem. But even so, you might consider doing it this way from within the theme’s function file, just to keep things all in one place. Of course, this is assuming that your CPT’s are tied in with the theme. If they are tied in with a plugin, then forget this answer completely.

    function setup_custom_posttypes() {
          // register post type 1
          // register post type 2
          // register post type 3
    }
    add_action('init','setup_custom_posttypes');