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
- Good way to store content and settings for an RSS plugin
- how to get post slug from url in wordpress
- Custom Post Type | Fatal Error on register_post_type()
- Set object terms not working on plugin activation
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- Navigation menus not showing because of custom post type filter
- GravityForm: Populate Dropdown with custom post type [closed]
- how to add extra meta box or textarea into custom post types
- Fake mark a menu item as current_page_item/active in WordPress
- “add_post_type_support” with Custom Post Type & ACF
- Shortcode insertion in tab
- Add/Remove current_page_parent class
- Can’t get order_by meta_value_num to work properly
- How to quickly reorder posts in the admin panel that will persist for the wp-api
- Add CPT as subpage under custom page
- Set the active Navigation Menu from a plugin
- WooCommerce product search titles only
- check if post title in a custom post type exists in page
- Should I use custom menu, C.P.T. or theme options, or something else for this?
- Set menu active state for custom posttype and category, given custom taxonomy term
- How to hack YARPP plugin to find related posts for custom post type?
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- One-to-many post relationships that are displayed by category (using posts-to-posts plugin)
- Function to display custom post type on front page makes menu items dissapear
- Custom posts don’t work
- How to retain $_POST data when submitting form to custom page
- Why get_posts() not returning only selected category posts from Custom Post Type?
- single-{cpt}.php ignored
- If post has custom field then display css-class
- Adding a custom post type taxonomy template in plugin
- Replace text in post from cvs
- Insert and then update post_type by wp_update_post
- Correct classes for WordPress menu items
- Custom Taxonomy Navigation, with current menu items for children?
- Customize the Dashboard Menu Editor
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- add category name to permalinks on product page /category-name/product-name
- Display posts from Custom Post Type in category page on front-end
- How can I make a custom post type sticky?
- Use menus with anchors
- How to make this menu drop down or like accordion
- Custom Post Type Nav to Subpage
- Custom Post Types don’t highlight in menu nav
- Querying both pages and posts
- Using default WP menu functionality to link to custom post-type listing?
- Second Set of Eyes: One custom taxonomy shows in Appearance > Menus, one does not
- How to automatically set ‘default image size’ for specific Custom Post Type
- Custom setting to show or hide field
- Action or Filter Hook for a Custom Importer
- How to set a CPT to have a page as a parent, then rewrite urls accordingly?
- Broken featured images are uploading from frontend
- Options page – dropdown of users
- Addition of custom option panel crashes Media Library & Admin Area
- limit value taxonomy based on previous taxonomy value wordpress
- Dynamic dropdown select values depending on other custom field value
- page menu entry for custom post type
- Tracking changes in admin-page so user gets warning when leaving the page
- How to change wp prefix for custom post type only?
- How to display custom WP menus?
- Send notifications to custom post author when custom post is edited
- Metabox not show in categories custom post type cmb2
- Post injections into Site Origins Page builder [closed]
- Custom Post Type + Categories
- WordPress randomly shows 404 errors
- Custom Post Type slug same as page name
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Shortcode for CPT post content in a page
- custom post type and non-standard gallery
- Make a custom_post translatable
- How to change permalink to include custom post type
- Is there a way to establish parent/child relationship in WP menu links exclusively?
- How to Add multiple instance of meta box to custom post type
- How can you use one database with multisite
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Use custom walker to add taxonomy terms to main nav menu
- A page that shows a list of a specific custom post type
- Adding custom image sizes and post types to a plugin or to a theme?
- Single custom post type’s menu ancestor/parent is Posts archive page
- menu link to custom post_type?
- Review site custom post type structure
- Custom Post Types in the WordPress Navigation Menu
- Custom fields for custom post type
- Custom Post Archive is not working
- How to add multiple images to a custom post type without plugin [closed]
- To use custom post types, or not to use
- Autocomplete or suggest from post titles inside plugin
- Show all tags on custom post type
- How we can create menu from Appearance > Menu and use as a add-submenu-page for admin menu?
- build child and anchestor three from post parent
- wordpress get menu id by custom post_type?
- cpt not display inside nav menu
- How to create a Child & Siblings menu for a custom post type?