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
- Wp forms wpforms()->entry->update not working on page refresh
- Show post count in custom taxonomy page
- Set a post expiration and delete a post when expirate
- Parent menu item does not display posts when I add the sub-items
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Count singular post views automatically
- Create/Set Category as Title of Post
- Reusing old post IDs
- Taxonomy checkboxes not showing current status on edit page
- Add a url parameter to the current post and read it in a shortcode
- Posts not showing content after migration
- Blocked posts in network tab
- How to distinguish pages created by woocommerce?
- Trigger on DB make problem on wordpress?
- Post images are not displayed in media library
- How to show WP admin edit page within template page/post?
- WordPress Screen Options, Help, Visual editor, Status, Visibility, Revisions, Published on and any toggled indicator don’t work for posts
- Centre Blog Index (Posts Page) on Home.php
- How to prevent post update using transition_post_status
- Dropdown Select Post Filter
- Blogposting Schema & Structured Data without plugin
- Order posts inside bootstrap card columns
- Save ACF with a save button on a post
- Delete attached images from posts
- Unable to edit or post after enabling SSL
- Exclude posts in a category on one page but show those posts on a different page
- Single post shows post three times
- What permissions does a role need for the user to be assigned as the author of a post?
- How publish post from pending status
- Hide or remove custom post status
- Template for displaying CPT / Taxonomy URL issues
- Countrywise Post View
- Multiple posts in one page
- post__in no longer works in wordpress 5.0.3
- Scrollbar disappear in post window
- long-title posts do not want published
- call to jquery ajax failing with 500 error when passing extra data field
- How to count posts in tags within time limit
- Automatically select template based on query string for New Posts
- How to create a button to filter posts (list) by meta value
- WordPress MySQL Search and replace with wildcard?
- Put page on Archived statut after end of publication date
- Moved a website and excerpts don’t work for old posts
- How to remove a post from results by ID after query?
- get_next_post() not working with future post status
- Why do I have categories with duplicate slugs?
- Blog featured images disappeared on my homepage
- Posting or Updating Article Fails on WordPress [closed]
- Blog images not showing on homepage
- How to display related post from same category in single.php