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
- Overview with latest edited posts and pages
- Side by side blog posts that are tied together
- posts_per_page doesnt work
- if I create ‘front-page.php’, then how do I link to post index?
- Will post_exists work for draft posts?
- How can I get a post field value using javascript?
- Check to see if post is live before displaying the content
- slideshow is not showing in a post call with ajax
- How to automatically apply a category based on the post title?
- How to disable edit post option 12 hours after post publication for contributors?
- Counter of posts ever posted – even deleted ones
- How to delete all the content of a wordpress site without deleting the Post and pages?
- WordPress’ ALL post count info on its dashboard does not match phpMyAdmin’s ALL post count!
- Update a users role based on number of posts published
- Style Differently Edited Posts
- 404 on paginated blog pages
- Blog page pagination is not working after using the offset argument
- Search results posts_orderby and ID
- How to add tags (custom taxonomy) to post class css?
- Sidebar show posts by current category also in single post
- Category Redirects to homepage [closed]
- SQL Command for restoring trashed comments
- How to split authors?
- Display Related Posts by Category in Random
- How do I keep raw HTML in my RSS feed and not lose my paragraph breaks?
- Featured Images most often doesnt appear
- Why is WordPress showing a blank excerpt for just one of my posts?
- Is there a way to know when a page has been updated and do some action only once?
- Reuse old post ID for new post after deleting post
- WordPress Pods Custom Post Type – separate Media Upload folder for each custom Post Types
- I need some explanation on global $post [duplicate]
- Order result from ajax
- Show post published live
- how i show manual data in a post
- How to get meta data from custom category name
- Show short text of content
- Need help writing loop to display posts by categories in separate divs
- Multiple Post Repeat for Related Post Loop by Category
- Fixing my display pending posts
- Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
- 2nd post different layout
- Print all content of a paged post
- How can i put image to come first than the title?
- Replace the attribute_escape to esc_attr()
- Is it possible to have different header style blog titles in different categories?
- Show last post of employee in his profile page
- How to disable edit post option? [closed]
- How to make posts appear under pages
- How to display only introtext?
- Default post type doesn’t display in url