try these changes:
1) To use add_action() when your plugin or theme is built using classes instead of passing just the function name, you need to pass an array with a reference to the class ($this) and the callable function (‘custom_post_type’)
function __construct()
{
add_action('init', array( $this, 'custom_post_type' ) );
}
2) The original ‘activate’ method called ‘custom_post_type’ suggesting that it only needs to be called once when the plugin is activated. But to properly register the custom post type, this method needs to be called every time WordPress is loaded which is why it is added to the ‘init’ hook. Calling it in the activate method doesn’t really make sense so I removed it.
function activate()
{
flush_rewrite_rules();
}
Related Posts:
- Remove POST_TYPE from custom post type permalink
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Add Excerpt On Quicksand Plugin
- 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
- register_taxonomy with multiple object type and update_count_callback
- Redirect after deleting post and keep track of pagination
- How often do you need to register_post_type?
- How to use a dedicated template for the Custom Post Type from a plugin?
- How to load a new template page according to a particular URL?
- Updating post meta for custom post types
- How to register custom post types in a plugin?
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to append element after thumbnail
- Best practice for adding posts in bulk
- How to have the right design for a custom post type without accessing themes
- Set object terms not working on plugin activation
- Get rewrite slug of custom post type in template
- custom post type not showing in menu
- Custom posts don’t work
- How to customize a permalink (URL) structure?
- Adding a custom post type taxonomy template in plugin
- Plugin: register custom post types, child ready and performance best practices
- Addition of custom option panel crashes Media Library & Admin Area
- Custom fields for custom post type
- Redirect to another page using contact form 7? [closed]
- ACF in wordpress
- How can I have different content for different countries?
- post_parent in custom post type
- How to insert data into meta box from another plugin?
- Custom post type’s posts are not showing anywere but in xml sitemap
- Unable to format dates to put in event calendar
- Custom post type in Custom widget – $listItem
- Add custom columns in custom post type browse page
- Validate Custom Post Type fields
- Types plugin custom post add_action hooks
- Convert Custom Table Data Based Plugin To Be Searchable
- how can i show a google map in custom post type
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Custom Post Type, Custom Columns List
- Check if theme supports sidebar
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Ultimate Members Default Post Layout problem
- custom post type and user post count shortcode
- Cannot view Custom Post Type no matter what I try
- Restrict Custom Post Type to One Item
- Custom Post Type Front Page Gives 404
- Show Post columns to specific users on condition
- Insert custom taxonomy into category query
- Run query on specific admin options page and send results to select field in another function
- Link two different post using there post_id in post meta
- Custom post type that lets users create a set of posts?
- Can’t save custom post type fields
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- get_post_types doesn’t work in plugin
- Registering an optional custom post type from a plugin
- Add category slug as class attribute in a link array
- Custom Post Types in plugins?
- Multiple Block Quotes without using HTML
- How to apply order on custom taxonomy and custom meta key on custom post type
- How to delete unnecessary custom post types in the UI
- Set a Custom Post Type as a Homepage
- How to Create Short Code Using Custom Post type
- How to hide home title on pages and posts?
- WP_Query is getting the post but the_post() not rendering any Post
- make playlist from a custom post type
- How to generate a responsive output from plugin?
- Custom Post Type to Plugin
- Woocommerce product page is not showing custom css [closed]
- Change the behaviour of archive cpt category and single cpt by plugin, not by theme
- Bulk update custom post types
- WordPress Code Access to Restricted Content without Registration
- add_filter > posts_where works partially
- Simple Share Buttons Add Plugin and Custom Post Type
- How to add image for custom taxonomy
- What can I do to customize a widget provided with this plugin? from where have I to start?
- WordPress Customise
- Exposing custom fields to the user in custom type post
- How to get ‘Products’ on home page?
- Slideshow/Gallery plugin based on WP Core Gallery [closed]
- Advise on Custom Taxonomies and Structure
- Why haven’t I see plugins using get_file_data to handle retrieving plugin version?
- Page template with custom query instead of archive-xxx.php?
- How to create an upload page (front side)
- How to create a job post by email parsing? [closed]
- Retrieve a post with its ACF repeater fields in wordpress
- WordPress Roles
- ACF select box css color change
- Need some hints for my own WP theme development
- How to dynamically register custom post type
- show posts under custom post type with same autj
- Creating post custom field text area
- Create settings page to enable or disable CPT
- How can I properly sanitize the update_option in WordPress?
- Create Custom Coupon Type
- Delete old thumbnail when updating new
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- cannot export data from CPT UI (books)