I recommend changing the form tag to:
This will ensure that the form submits to the same page it is on.
Also post_title and post_content are required, so the insert will fail if either of those values are blank or missing. (https://developer.wordpress.org/reference/functions/wp_insert_post/)
Related Posts:
- Creating a post from data returned from HTML form
- Create posts on user registration
- post__in for get_posts with a dynamic array
- Using $wpdb to query posts with meta value containing current post_id
- Create posts without login from frontend
- WP_Query to work with custom view
- Posts added with wp_insert_post are moved to trash automatically
- Prevent duplicate posts in wp_insert_post using custom fields
- duplicate posts when trying to update a post using the wp_insert_post.
- Create new WordPress post [wp_insert_post] based on results of a WP_Query
- Custom Post Type & Author not associating, user post count is 0, api doesn’t return author in post objects
- Replace Main Query With Custom Query
- generate unique slug while inserting post
- get posts and postmetas in assoc array
- How do I batch create revisions of all posts?
- wp_insert_post works, but the post isn’t visible in the admin post list or front end
- Can’t get wp_insert_post to work
- Email Post Attachment on wp_insert_post Action
- post_content sanitization / transformation process
- wp_insert_post – duration
- How to prevent duplicate posts with wp_insert_post on single.php?
- How to do set post permalinks using 6 digit random unique function?
- Using $wpdb to fetch posts with meta data
- wp_posts table: safely remove unused columns to save database storage
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- post category in wp_insert_post
- Why Query is returning empty array?
- When creating a post how do you select the format?
- meta_value timestamp older than now
- Displaying post excerpt using wpdb query
- Adding post date will not insert new post
- Retrieving posts by their date and category
- wp_insert_post not working fine
- Insert data from custom created PHP page into wp_postmeta table
- remove all custom post created
- query for filtering published posts?
- How to save template data into wp_post table (post_content column)
- How to let a user create a post by submitting a POST form?
- wp_insert_post() Add and specific ID to the body of that
- Random post_id at wp_insert_post
- how to create a category with wp_insert_post and post_category
- Top tags with minimum number of posts
- Create posts by any logged in users
- Creating a frontend blog post form for logged in users only
- I am not getting result from php function that is json encoded
- Save/retrieve form data best practises for theme development
- Insert new post for each user infinite loop error
- Is there any point to using wp_unique_post_slug?
- Admin notice on wp_insert_post
- WP_Query post_tilte search in posts table
- How to disable content pagination?
- How to add/assign or change featured image in post programmatically?
- WP-CLI Bulk delete posts from specific category
- Update all posts automatically when using post_meta
- Exclude ALL posts from sub categories
- Post ids are incrementing by an unknown number?
- Can’t show comments count per post outside loop
- Redirect based on user post count
- Should our pages be posts?
- Allow role to delete posts but block him the wp-admin
- How to Add ‘Post Categories’ to the Dashboard Sidebar
- Remove the Edit button in posts for permalinks on certain user roles? WP 3.3
- Show total author’s post views by posts post_meta
- Why is my Blog Page ID == First Post ID?
- Custom loop pagination links not working
- If in_category not working for multiple single.php pages
- Thumbnail & Category link aside post
- My wordpress based site is publishing the same post twice
- How to make a sum of all posts displayed in a loop
- First x post with another template then the others
- add bootstrap post slider with tabs
- Show all posts shows a blank white page in WP 4.2.2 [closed]
- single post showing blank page in custom template
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Get total post from an author
- How to embed the content of one post into another site
- Prohibit saving a post without providing a title
- Standalone form does not post to the url when form fields are populated (otherwise it does)
- Will multiple category descriptions effect my search engine optimization?
- How to prevent to create same url of post, if the previous was deleted?
- ‘QTags.addButton: arg2 distorts the button rather than just shows
- WordPress Post 403 Error Based on Slug
- How to add first 3-4 post tags on WordPress Post Title
- WordPress React re-rendering to many times
- How to add class to specific navbar item when post parent category is in specific category
- Posts are not displaying on their category and tag page
- Adding a ‘section’ to the backend menu
- Get 5 most recent categories
- List of authors posts minus very latest
- Add category attribute to custom recent post shortcode
- How can I show my post under a certain content name?
- How to display only one post on first category page and rest on next pages?
- Show Custom Post From Logged In Author
- How to display a paginated list of posts from one category on a page? [duplicate]
- Is there a way to separate wordpress titles from their posts?
- custom sort posts in archive/taxanomy page
- Show some texts in posts belonging to Specific category
- Undefined Function Fatal Error with Shortcode [closed]
- How to sort posts alphabetically based on a specific parent category
- Is it possible to use the_post 2 times in one loop