Importing custom post types using WordPress Importer, how to check for meta field values

I guess you want to modify these lines in the WordPress-Importer plugin:

$post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {

to add some post meta checks.

I don’t see any hooks inside the function post_exists() that we could use.

Remark:

I don’t recommend editing plugin files, but if this is a one time import and you can’t find any other solution, then you might give it a try.

Idea:

So you could try to replace the above lines with the following snippet:

$post_exists = post_exists( $post['post_title'], '', $post['post_date'] );

//
// if the post exists, let's check if it has the right post meta stuff
//
$my_meta_key = 'url'; // Edit this to your needs
$meta_exists = FALSE;

if ( $post_exists > 0 && isset( $post['postmeta'] ) ) 
{
    foreach( $post['postmeta'] as $meta ) 
    {
        if ( $my_meta_key === $meta['key'] ) 
        {
            if( $meta['value'] === get_post_meta( $post_exists, $my_meta_key, TRUE ) )
                $meta_exists = TRUE;

            break;
        }
    }
}

if ( $post_exists && $meta_exists && get_post_type( $post_exists ) == $post['post_type'] ) 
{
   ...

where you must modify the $my_meta_key to your needs.

This idea is untested so remember to take a backup before testing.

tech