I believe the problem is here:
// handle AJAX calls for both logged in and guest users
add_action('wp_action_websites_cpt_create_post', [$this, 'create_post']);
add_action('wp_action_nopriv_websites_cpt_create_post', [$this, 'create_post']);
Because the format should be:
add_action( 'wp_ajax_{ACTION_NAME}', [ $this, 'create_post' ] );
add_action( 'wp_ajax_nopriv_{ACTION_NAME}', [ $this, 'create_post' ] );
..where {ACTION_NAME}
is the “action” name, e.g. websites_cpt_create_post.
See wp_ajax_{$_REQUEST['action']}
and wp_ajax_nopriv_{$_REQUEST['action']}
.
Related Posts:
- Custom post type’s extra fields – how to handle?
- ajax response not recieving
- How to filter custom post data with AJAX?
- Getting the URL of the parent page
- Hook to override title, image and content
- 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?
- Ajax Check Post Status
- get_object_taxonomies() returns empty array for custom post type
- WordPress theme custom capabilities not works
- custom post type not showing in menu
- Custom posts don’t work
- Received nothing after executing AJAX post function
- Filtering WP_Query Dynamically on the Front-End
- No posts found – Custom Post Type show_ui
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- How to customize a permalink (URL) structure?
- Adding a custom post type taxonomy template in plugin
- Loading custom content type from ajax results?
- Plugin: register custom post types, child ready and performance best practices
- How to add a custom taxonomy to show up in a custom post type menu?
- Give a permalink to Custom Post Types without title
- Getting template_include to work when allow_url_include is off?
- How to add a custom-post-type post within another custom-post-type post edit screen using AJAX?
- WordPress post_where & posts_join not working only for custom post type
- AJAX load more for different custom post type loops
- Add custom ID to CPT posts only create not update
- Add custom post type as submenu [closed]
- WordPress multiple custom post types capability conflict in a single menu
- Ajax Custom Post Filter is not filtering
- Getting meta in editor plugin, and event triggering issue
- Orderby CPT custom fields not working
- Unable to get Custom Plugin Options data
- Update post meta not working in transition_post_status
- WP_Query inside foreach loop returning same value for all options when filtered using ajax
- Use custom metabox to update automatically a post after a given date
- JS innerhtml changing style when using AJAX
- Addition of custom option panel crashes Media Library & Admin Area
- Custom Permalink to remove category word , keeping posts permalink with date?
- Custom post type – use ajax to display sub pages
- Form action/link to render a plugin in WordPress front-end
- What is the best practice for displaying my plugin content in themes?
- Custom post type archive page blank
- Add Custom Post type menu to another menu in specific location
- Set a CPT slug as a base name for all the taxonomies
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- How to use TinyMCE Editor for one of my custom post meta field?
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Load Custom_post_type categories post with ajax
- Custom post listing page layout of custom post type
- How to Get WordPress custom post data in WooCommerce product meta panel? [closed]
- Dynamic Custom Fields
- A custom post type in another post type
- Adding a metabox on a CPT’s submenu page
- Deleting taxonomy terms and relationships on a custom post_type when a user is deleted
- Load Next Posts With AJAX not working with custom post type
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Plugin fatal error
- custom comments form for custom post type
- Wrap meta boxes & data handling for specific post types in classes?
- Problems wp_insert_post and save_posts filter
- Retrieve custom post types by custom taxonomies with WP_Query
- Custom fields for custom post type
- Suggestion on custom post type/ taxonomy relationship
- $post not working working in AJAX plugin with custom post type
- wordpress remove views from action links in a custom post
- When should I create custom post types?
- Load Next WordPress Posts With AJAX?
- Save Multiple Metabox values
- 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
- Main query not querying any posts in custom taxonomy template
- Custom Empty Results page for my Custom Post Type
- detect your custom post type in WordPress
- ACF in wordpress
- Theme independent plugin by using default page template
- Option page’s form doesn’t work
- admin-ajax.php GET custom-post titles
- How to add and clear custom post types and taxonomies in a plugin? Considerations for existing data
- post_parent in custom post type
- How to group navigation items in the admin panel
- What’s an efficient way to change the post status of many posts at once?
- How can I include active content in a custom post type?
- Post will not load via ajax
- Dynamically insert code to custom post type loop
- Show current custom taxonomy
- Select2 AJAX and WP Query Returns ALL and does not filter
- How to insert data into meta box from another plugin?
- How exclude or skip post type with get_next_post_link
- 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?
- How do I add custom HTML to the content of an archive page’s posts?
- How do you make a list and list item relation if custom post types?
- Add to ‘action’ within post.php to allow more actions when editing a Custom Post Type in a plugin
- Add form after woocommerce admin order edit
- Custom Meta Box returns no HTML
- Unable to format dates to put in event calendar