Try to use wp_update_post()
in place of wp_insert_post
for update.
$id = wp_exist_post_by_title($post['post_title']);
if($id !== false)
{
$post['ID'] = $id["0"];
// Create Post
$post_id = wp_update_post( $post );
} else {
$post_id = wp_insert_post( $post );
}
Related Posts:
- How Can I Set the Post Author of a Post I Just Created With PHP?
- Post author for revision not being set on update/insert
- Get post ID from wp_insert_post()
- WP insert post and custom taxonomy
- Automatically fill custom field value on post publish/update
- How do I programmatically add items of content to a custom post type?
- modify all posts of a category to “no comments allowed”
- Not Able to Insert Taxonomy Term Using wp_insert_post()
- Ordering Post 2 Post admin meta box by meta from CPT
- How I upload, save and set a featured image from my frontend?
- Create Pages from Database
- Trying to save custom post type from frontend partially working
- How do I write this SQL statement for Posts written in last 24 hours?
- wp_update_post on specific custom post type
- wp_insert_post custom taxonomy
- Assign category to front end post
- Combine tax_query and meta_query in WP_Query
- How can I programmatically save data into custom fields that contain serialized data?
- What hook should be used to programmatically create a post only when master post is updated?
- Query to change custom post type with specific category
- wp_update_post based function works on existing posts, but not new posts
- WordPress tax_input only if logged in
- Programmatically adding posts
- Mass convert MySQL data entries into custom post type?
- Calculating Bayesian average for custom post type
- Updating post title using wp_update_post
- Is it possible to create a post using a metabox?
- How to auto increment post title & post slug field?
- Auto-generated posts not showing in backend (but being counted!)
- Deleting Custom Post type data using mySQL command
- wpdb custom post_type problem
- Adding custom tables to WordPress
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- wp_insert_post generates endless posts
- Insert post metadata for all posts in CPT at once if metadata no existent
- Convert simple SQL Query to WordPress query
- Insert and then update post_type by wp_update_post
- Posts are duplicating on wp_post_update
- create parent post using wp_insert_post
- Cron job for creating posts not excecuting properly
- How to checked selected category checkbox when my custom post inserted from frontend
- Assign External Database Queries to Global Variables and Make Them Accessible
- How to import a custom MySQL DB table into a WordPress custom post type
- Function causing the loop display posting more (empty)
- Add CPT values to Database
- wp_insert_post sometimes fails after API call
- Why cant I add a custom post type to a custom taxonomy?
- Proper way to display latest 5 posts grouped by post type?
- How to automatic update date and time when save custom post type
- wp_insert_post wrong post type [closed]
- Programatically inserted posts not showing in Posts Table
- Programmatically change post visibility on save_post action return a 500
- Front end access to a SQL data repository – recommended way?
- Navigate posts with different post type that are in the same categories
- Is it possible to add posts and images (auto resize) for custom post types with a script?
- Why does wp_update_post causes white screen?
- WordPress hook which triggers on post import
- How to handle new post from API request?
- How to handle this specific case of custom post type?
- I’m trying to create a custom version of the wp_list_authors function that includes custom post types
- Odd behaviour for the update button when displaying a WP_List_Table
- New post from database
- insert image with custom post type
- importing table data to custom post type
- How can I get some of a posts meta data whilst it is still inserting?
- Convert Custom Taxonomy Posts to Normal Posts
- How to import database table as custom post type and custom fields?
- $wpdb is queried but results don’t show
- How to keep a record of changes to a custom field?
- SQL query – get ids – Advanced Custom Fields / WPeC
- Why doesnt my tag page populate with this custom post type?
- Fetch data of 2 relational Custom Post in WordPress
- See if the email exists or not
- WP_Insert_Post creating duplicate posts when logged in
- Updating a custom post status after an expiry date rather than trashing it
- wp_insert_post from XML feed only inserting first post
- What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
- How do I find out which (page) template file my custom child post is looking for?
- Custom post type and custom taxonomy key lenght & query performance
- wp_insert_post deleting previous post custom meta
- Change the term based on the value of a $variable using wp_update_post in submitting a form
- Why is this function so slow?
- Sql Update CPT from publish to draft and particular custom field
- Published page but it is page not found
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- How to insert post 6 times after user register like ask.fm
- update flamingo_inbound post type after insert
- wp_insert_post() creates duplicates with ‘post_status’ => ‘publish’
- save_post affect creation and deletion
- automatic creation of custom post type articles
- Post that populates itself (almost) automatically using data from imported excel file
- Populate custom post type/custom fields from an external database
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Can I override the permalink/slug on creation
- Custom post order when using OR relation
- Custom Post save causes 500 error
- Generate slug and meta data if meta field is empty
- Add a image to a post published on a CPT from the front-end
- wordpress form processing to custom post type not working