The init
hook is the first hook allowed. If called earlier it won’t work.
See WP Codex: https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/
Create or modify a post type. register_post_type should only be invoked through the ‘init’ action. It will not work if called before ‘init’, and aspects of the newly created or modified post type will work incorrectly if called later.
Related Posts:
- How often do you need to register_post_type?
- Types plugin custom post add_action hooks
- How to enqueue scripts on custom post add/edit pages?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Prevent trash/delete action on specific post types
- How to add custom content template part for a custom post type on main query using a plugin
- When can you get current page ID and initialize hooks right after?
- Unregister post type from child theme
- How to add a button to custom post type’s posts-page
- Why The Init Hook For Custom Post Types
- flush_rewrite_rules on save_post Does Not Work on First Post Save
- register_taxonomy with multiple object type and update_count_callback
- Using the ‘draft_to_publish’ hook (post status transition)
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- How to use a dedicated template for the Custom Post Type from a plugin?
- With what hook can I address all posts from all custom post types when they are published?
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- WordPress custom post action hook
- Remove POST_TYPE from custom post type permalink
- What hook should be used to programmatically create a post only when master post is updated?
- Actions that Run on Admin Edit Page Load After Posts Are Queried
- Is it possible to add an action to the currently running action?
- How to append element after thumbnail
- Remove “Get Shortlink” button in admin of custom post type
- How to prevent action in ajax request, when in admin side?
- template_redirect not being called when using ajax
- How to have the right design for a custom post type without accessing themes
- What are the benefit in adding hook in the init() hook?
- Custom Post Type | Fatal Error on register_post_type()
- Set object terms not working on plugin activation
- add_action in functions.php, do_action in plugin?
- Can’t unregister parent theme’s CPT from my child theme
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Insert Multiple Post with Same Publish Button
- Why is conditionally loading a custom plugin’s code only on a specific custom post type causing the site content to disappear?
- How to: Display ACF [fields] on Custom Post Types Utilising WordPress ‘Hooks’? [closed]
- custom post type not showing in menu
- Custom posts don’t work
- Adding a custom post type taxonomy template in plugin
- Any hook for pre-plugin-update -either bulk or single plugin update
- How to get all of the activate_plugin action parameters?
- Addition of custom option panel crashes Media Library & Admin Area
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Filter Posts from the Main Query
- Custom fields for custom post type
- Use remove_meta_box conditionally on custom post type
- ACF in wordpress
- post_parent in custom post type
- wp_trash_post action hook with custom post type
- How do I amend form data before it is saved for a custom post type
- Hook for page Request?
- Unable to format dates to put in event calendar
- Custom post type in Custom widget – $listItem
- Validate Custom Post Type fields
- Creating alternate meta box context locations
- wordpress post_where set only for my costum post type
- What hook can I use to modify custom post data before it is displayed on the page?
- how can i show a google map in custom post type
- How to recover the post ID earlier in the WP admin hook action “firing” sequence?
- Using `set_transient()` when saving a custom post type
- Using publish_{custom-post-type} hook for custom post type to update meta doesn’t work
- Plugin Development using classes – Public & Private Callbacks
- The function called on the wp head hook becomes null
- Changing CPT permalink
- Passing function into add_action always returns the first argument
- Restrict Custom Post Type to One Item
- Custom Post Type Front Page Gives 404
- Show Post columns to specific users on condition
- Correct way to register custom post type from external php file?
- Insert custom taxonomy into category query
- How to store additional data that is related to core data
- Run query on specific admin options page and send results to select field in another function
- Custom post type that lets users create a set of posts?
- call a function when insert and update a custom post type
- Can’t save custom post type fields
- Execute code only after user clicks ‘update’ button for CPT being edited
- Custom Fields as Post Type Options
- get_post_types doesn’t work in plugin
- do action inside a class is not working
- Customizing a plugin function using a hook
- Plugin Hook: Get posts
- Add Excerpt On Quicksand Plugin
- Custom Post Types in plugins?
- Create action running on trashed_post hook to modify post_meta value
- How wordpress plugin hooks works? [duplicate]
- Admin Post Update Redirection to Posts Screen
- Unable to filter on field on edit.php page
- update_post_meta() whenever custom post type is updated
- Get image URL from media library in input
- add action wp_head not working
- custom post type and non-standard gallery
- WordPress Custom Post Loop
- WordPress Plugin Boilerplate – add actions and/or filters based on user’s role
- Create Inclusions and exclusions
- Custom Info Box at end of posts?
- Insert plugin html content to a specific spot in the frontpage
- public custom posts not showing in my wordpress plugin