I initially misunderstood your question completely (too much tea, too focused on my initial idea of what your problem is instead of carefully reading ;).
I believe that the problem isn’t that the menu is already created (admin_menu
runs after init
) but rather that registerPostType
will only run in init if it is enabled (and not when it is being enabled).
Moving the if ($this->enabled) {
into registerPostType
and running it unconditionally on init
, e.g. just putting
if (!$this->enabled) return;
at the top of registerPostType
and changing
// Register custom post type if enabled.
if ($this->enabled) {
add_action('init', array($this, 'registerPostType'));
}
to
// Register custom post type if enabled.
add_action('init', array($this, 'registerPostType'));
seems most logical to me.
Related Posts:
- custom post type not showing in menu
- Redirect to another page using contact form 7? [closed]
- Run query on specific admin options page and send results to select field in another function
- Possition a Custom Post Type Tab under Settings
- Custom Fields as Post Type Options
- How to display custom post type in a submenu?
- Custom Post Type parent slug as menu item
- Plugins for putting Custom Post Types into the Menu
- Highlighting wp_nav_menu() Ancestor Class w/o Children in Nav Structure?
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- How to Add Custom Taxonomy To Woocommerce Plugin
- Development of a WordPress Search Plugin – Best Practices
- Creating “static” taxonomies to choose from, inside custom post type?
- Rewriting ‘rewrite’ slug for custom post type used by plugin
- How can I get my Custom Post Types to appear in nav-menus.php ‘Menu’?
- automatically placing custom post types singles into submenu of main nav menu
- Renaming Menu Item within Admin Menu Section for a Custom Post Type?
- How to Programically add to the new WordPress menus
- Possible to add another setting to ‘Front page displays’ setting for Custom Post Type
- Getting arguments for register_post_type from a plugin generated post type
- update custom post type meta from a shortcode
- How to localize value of posts
- How to register custom post types in a plugin?
- Display custom taxonomy as dropdown list
- Editor access to menu: custom post type missing
- Settings page above CPT page in admin section
- Remove current_page_parent from posts page link in WordPress nav menu
- How to append element after thumbnail
- Menu highlight custom post type archive
- Best action hook to create custom post and assign taxonomy terms to it on plugin activation?
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- wp_nav_menu() mark current item ancestor of custom post type
- Menu Multiple Taxonomies
- Shortcode insertion in tab
- Add/Remove current_page_parent class
- Add CPT as subpage under custom page
- Set menu active state for custom posttype and category, given custom taxonomy term
- Adding a custom post type taxonomy template in plugin
- Correct classes for WordPress menu items
- Customize the Dashboard Menu Editor
- How can I make a custom post type sticky?
- Custom Post Types don’t highlight in menu nav
- Broken featured images are uploading from frontend
- limit value taxonomy based on previous taxonomy value wordpress
- How to change wp prefix for custom post type only?
- Metabox not show in categories custom post type cmb2
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Single custom post type’s menu ancestor/parent is Posts archive page
- menu link to custom post_type?
- Custom Post Types in the WordPress Navigation Menu
- Custom fields for custom post type
- Custom Post Archive is not working
- Custom Post Type & Custom Menu Walker to append custom class for active post types
- Create metaboxes based on custom post type
- How can I have different content for different countries?
- How can I use archive-{post_type}.php theme template?
- Custom Post Type Link added to menu won’t show in frontend
- How To Display A List Of CPT Posts In A Meta Box On Menus Page?
- populate array with posts
- Get custom post type categories to show up in menus
- custom permalink for post only not custom post types
- CMB2 metabox create select with list of post from CPT
- Methods for development wordpress themes [closed]
- Overriding Plugin Function in Child Theme
- Custom post types, disable fields
- Types plugin custom post add_action hooks
- How to programmatically add elements in a custom menu
- Creating on-page options for Custom Post Type
- Custom Posttype and menu classes
- How can I increase the post count for custom post types only?
- Menu for taxonomies and posts belongs to taxonomy
- cpt not display inside nav menu
- How to create a Child & Siblings menu for a custom post type?
- Custom Post Type works when registered in functions.php but not when registered in plugin
- Reading Custom Post data so I can have user update Manually
- How to show link to product in custom fields?
- CPT UI: Connect a custom post type to a custom post type
- How to check if a new private custom post type is created?
- Custom post type category link + add to menu
- Looping through image object using ACF and CPT UI [SOLVED]
- Navigation not working for custom post type pages
- How to create groups like that in buddypress?
- Post that populates itself (almost) automatically using data from imported excel file
- I broke it! Custom post type archive gets redirected to home
- Can’t save custom post type fields
- How to Create movie schedule by custom post type query
- How to load custom post type plugin after acf options page (or get settings from there another way)?
- Custom nav menu current item custom link problem
- get_post_types doesn’t work in plugin
- Customizing a plugin function using a hook
- List all posts from custom post type by taxonomy
- how to override menu widget?
- CPT Archive with parent page
- Extending a CPT by Created by another plugin
- Show posts of parent in edit.php
- current_page_item and custom post type?
- Menu that shows months and filters posts to show only posts from that month and shows posts as sub items
- Display Custom Post Type on Toolset Types Plugin
- sidebar hierarchical menu category & custom post type
- Retrieve a post with its ACF repeater fields in wordpress