wp_enqueue_scripts action is not meant to add PHP code to your page. It is used to add JS scripts.
https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/
wp_enqueue_scripts is the proper hook to use when enqueuing scripts
and styles that are meant to appear on the front end. Despite the
name, it is used for enqueuing both scripts and styles.
If you want to handle your post submission, you can use the init or admin_init actions (if you are on the public website or the admin section). You might need to hook wp if you need to access the global $post object.
Do you get anything in your error handler? Can you check that you correctly get your posted data with var_dump($_POST);?
Does your post type channels is registered somewhere, your current user needs to be allowed to create the post type. You should check the capabilities that you set when registering your post type. https://developer.wordpress.org/reference/functions/register_post_type/
Related Posts:
- Inconsistent temporary 404s on whole install | PHP error with post-template.php
- Get post ID from wp_insert_post()
- Search that will look in custom field, post title and post content
- Get custom post type by category in a page template
- Is it possible to create an “export to PDF” option?
- If featured image doesn’t exist, show post content
- How can I add dropdown widget/box to admin post page?
- Reason action hook won’t work with update_post_meta from frontend form? Alternative?
- Clean URL permalink for custom post type
- How can I fix a slow redirect after form submit from frontend (no plugin)?
- WP insert post PHP function dynamically generated Custom Fields
- Inserting data into `post meta` table?
- Error after deleting Custom Post Type with a function (no trash used)
- Change message given when deleting post from custom post type
- How to append element after thumbnail
- I am having a problem with form updating/editing WordPress post on the frontend
- Custom Post Type without an archive page
- Dynamic page outside WordPress
- Custom query to filter posts that have current post as a taxonomy [closed]
- Pagination for custom php code
- Custom Post Type Loop throws 500 error when used in widget
- Received nothing after executing AJAX post function
- Troubles with saving metabox
- AJAX load more for different custom post type loops
- Changing wordpress publication date to ACF date and time picker date not working
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- creat filter with wp_query
- WordPress custom post type permalink rewrite shows page not found
- Categorize custom post type
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- Function causing the loop display posting more (empty)
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Foreach inside shortcode not working as planned
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Using POST method in meta box, no results
- Problems wp_insert_post and save_posts filter
- categories should be available across all custom post types
- Cant get paginations on single.php to work with my custom post types
- 404 Error on form submission within custom post type
- How can I group posts by months and years?
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- Not sure why this template for custom post type posts isn’t displaying anything. What’s missing?
- Custom Post not working as expected
- Saving fields in a drop-down in WordPress
- Assigning a category to a custom post type in WordPress
- Show current custom taxonomy
- finding and using post type fields in WordPress
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- Show message when query has no posts
- Query entries from custom post type in an ACF flexible content field
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Template code to split a post and print a custom field?
- Direct form to a custom page template
- Accessing a protected property of a post
- Foreach loop returning more than one item when querying taxonomy
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Post type Echo code is repeating on homepage
- Need help with simple “if statement” checks to output particlular CPT data depending on what client uploads/fills out
- How can I increase the post count for custom post types only?
- WordPress sitemap with Custom Post Types
- How can I sort the order of multiple custom field values in a custom post type?
- Custom post type page with parameter
- Display All Courses in Course Archive Page
- Custom fields array to display it monthly
- How to show the post which checkbox is not selected
- php dynamic content inside shortcode
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Is it possible to hide nav menu items only when they are page titles (on specific templates) but not on the dashboard?
- Get all post under custom post type grouped by custom filed value in custom taxonomy
- Check that a slug is present in the get_terms request
- open custom post type in popup window instead of page
- Get category name of custom post type
- when looping through custom post data not appearing
- How to submit the date with ajax?
- Getting a Post ID to show its content in a Popup
- How to limit the number of custom posts certain users can publish in WordPress using php script?
- Load info from customposttype into template page
- Visualize info in just custom post_type in theme
- cpt not display inside nav menu
- Disable Sidebar on certain pages
- Show parent category and subcategory once in while loop
- How to get the posts that my following users are liked?
- Display related post content and custom field content
- Custom 404 redirect for a luddite
- Show tags of custom post types in WordPress
- can’t see categories in appearance-menu-categories
- wordpress form processing to custom post type not working
- WordPress custom field images not getting inserted into array
- Meta-Box to add multiple items one at a time and on publish save all
- Values inside a custom field to determine which category posts to display
- Forms with multiple element types using custom post types
- Posts without featured image using other post’s featured image
- Add number in increment of one to DIV ID
- Building a List of Posts grouped by custom taxonomy as the section header only to be displayed if at least one post is in that tax
- What is the most efficient way to manage changes my product comparison tables?
- Send email on creation of custom post type and use get_post_meta()
- Just the First Metabox what saves the data!
- Is there a way to edit non-custom term attributes?