0

I have the following code to insert posts in wp_posts table using wp_insert_post function:

http://pasted.co/c3fcb315

I'm using Polylang for this CPT called "Property", posts must be set in two languages: Spanish and English. The insert part is working like a charm but I don't know how to deal with the update process (wp_update_post).

Jorge Rivero
  • 1
  • 1
  • 3

1 Answers1

0

https://codex.wordpress.org/Function_Reference/wp_update_post

You are not passing the id in the first part of your loop:

if ( ! $propid ) {
        $post_args = array(
            //NEED ID TO UPDATE WITH WP_UPDATE_POST
            'post_title'   => $property['MLSNumber'],
m33bo
  • 1,334
  • 1
  • 17
  • 34
  • I'm passing the ID in the else clause: else { $post_args = array( 'ID' => $propid->ID, 'post_title' => $property['MLSNumber'], 'post_content' => $property['Remarks'], . . . } First block is for insert, the second is for update if post already exists. (I'm getting this data from the client server) – Jorge Rivero Dec 15 '17 at 18:35