Since the activation hook only will be called when activating the plugin, you will instead need to call register_post_type() on some hook which is triggered every time you access the administration pages. You could use the init hook for this:
add_action('init', array($this, 'register_custom_type'));
You also need to make the register_custom_type() method public for this to work:
public function register_custom_type()
{
// call register_post_type()
}
Documentation
Note: Post type registrations should not be hooked before the ‘init’
action. Also, any taxonomy connections should be registered via the
$taxonomies argument to ensure consistency when hooks such as
‘parse_query’ or ‘pre_get_posts’ are used.
Related Posts:
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Custom Post Type Plugin: Where Do I Put The Template?
- Creating a Custom Post Type as a Plugin? Why?
- Is flush_rewrite_rules necessary when creating a custom post type? Why?
- Unable to filter on field on edit.php page
- Custom Taxonomy and tax_query Issue?
- Using posts and postmeta table to store custom Address Book Plugin data
- template_redirect not working, apparently for no reason
- Custom role capabilities to administrator not taking effect (no plugin)
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- How to append element after thumbnail
- handling csv data with a custom post type
- Custom Post Type | Fatal Error on register_post_type()
- Custom Post Type rewrite
- Admin notice not displaying
- Detect where custom post type is declared
- Insert Multiple Post with Same Publish Button
- get_object_taxonomies() returns empty array for custom post type
- custom post type not showing in menu
- Adding a custom post type taxonomy template in plugin
- Plugin: register custom post types, child ready and performance best practices
- Add custom ID to CPT posts only create not update
- Add custom post type as submenu [closed]
- Getting meta in editor plugin, and event triggering issue
- Unable to get Custom Plugin Options data
- What is the best practice for displaying my plugin content in themes?
- How to use TinyMCE Editor for one of my custom post meta field?
- Deleting taxonomy terms and relationships on a custom post_type when a user is deleted
- Wrap meta boxes & data handling for specific post types in classes?
- Send a conditional email notification when a custom field value changes in Post Type
- WordPress custom post type capabilities issue
- HowTo: Custom Post Type (Meta) to Custom Table
- how to set a WP Plugin’s url
- Custom Empty Results page for my Custom Post Type
- detect your custom post type in WordPress
- Option page’s form doesn’t work
- How to group navigation items in the admin panel
- How can I include active content in a custom post type?
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- How to access the thank you page from the single post?
- ajax response not recieving
- Custom Meta Box returns no HTML
- Add post type pages with plugin
- shopping cart plugin development
- How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop
- CPT to installable Plugin
- how can i show a google map in custom post type
- Most viewed post of custom post type
- filter the_content, custom post type, and wp_query
- Fill custom fields when saving custom post types
- How add column from new table in Custom Post Listing (admin)
- Custom post type page with parameter
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Custom post category name showing empty
- allowing custom user role to access custom post type in wordpress admin
- How to show the post which checkbox is not selected
- Is it possible to get the specific content on the search page?
- Get next and prev item from custom WP_Query and Custom Post Type
- How add Filter by Tags and by categories to custom post type in Gutenberg block
- Error 404 change permalink term custom term taxonomy
- Show a custom post title in another custom post type in Meta box
- I have a random letter appearing before my content. Where to start looking for the cause?
- How to select meta key in custom database query
- Restrict Custom Post Type to One Item
- How to seperate posts by categories?
- How to Use A Custom Post Type as Taxonomy for Another Custom Post Type
- Widget area for individual posts (custom post type)?
- How can I load Template file from wordpress plugin
- Which File Populating CPTs in Slug URL
- Front End users account with lots of user Roles (not Woocommerce)
- How save custom meta type posts multicheck grouped by taxonomy (with CMB2) [closed]
- Custom post type that lets users create a set of posts?
- How to reset HTML filter input fields on CPT list page?
- Foreach in get_post_types to apply a different filter per post type
- How to develop custom URL redirection
- In WordPress do I create tables for my plugin or do I create custom post types for a Student and Classes Registration system?
- Execute code only after user clicks ‘update’ button for CPT being edited
- Can the wp_posts table have the same slug (post_name) in multiple statuses (post_status)?
- Display custom post type archive on page.php template
- Show Templates in Custom Post Type Editor
- How to avoid hardcoded text in a custom page template?
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- Add category slug as class attribute in a link array
- How to use get_sidebar in plugin folder?
- Custom post types working in functions.php but not in plugin
- Resources to learn OOP for WordPress plugins, custom post types, etc
- How to create an upload page (front side)
- How to dynamically register custom post type
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- Custom Post Type urls not working
- I want to show a list of post with title that have link goes to that post and icon under the specific category to which it belongs
- Custom post type template not loading from plugin
- Redirect to All Custom post types
- I am having a problem with fetching product data in the Gutenberg block editor
- Add block templates (html) via plugin for custom post type
- how can i call archive-{post type}.php template from my custom plugins to my theams?
- REST API callback function is not called
- Add taxonomy or category slug to custom post types URL
- Redirection after saving a post
- How to fix post_tags not showing for a CPT in new post for a custom user role?