wp_import_existing_post

Filter ID of the existing post corresponding to post currently importing.

Description

apply_filters( 'wp_import_existing_post', (int) $post_exists, (array) $post ); 

Return 0 to force the post to be imported. Filter the ID to be something else to override which existing post is mapped to the imported post.

Parameters (2)

0. $post_exists (int)
Post ID, or 0 if post did not exist.
1. $post (array)
The post array to be inserted.

Usage

To run the hook, copy the example below.
  1. $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post ); 
  2.  
  3. if ( !empty( $post_exists ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_import_existing_post callback 
  2. function filter_wp_import_existing_post( $post_exists, $post ) { 
  3. // make filter magic happen here... 
  4. return $post_exists
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_import_existing_post', 'filter_wp_import_existing_post', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_import_existing_post', 'filter_wp_import_existing_post', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wordpress-importer.php  
  1. $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post );