Support » Plugin: Import any XML or CSV File to WordPress » Detecting Duplicate Titles

  • Is there a way that I can get the plugin to skip imports that have a duplicate title to a post already published on the site?

    Thanks,

    Gary

Viewing 1 replies (of 1 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @garywright

    You can use the ‘wp_all_import_is_post_to_create’ hook for this.

    For example, if you’re importing “Posts” and the {title[1]} element contains the post title in the import file, you could use this snippet:

    function my_is_post_to_create( $xml_array, $import_id ) {
    	$title = $xml_array['title']; // {title[1]}
    	$existing_post = get_page_by_title( $title, 'OBJECT', 'post' );
    	
    	return ( $existing_post == null ) ? true : false;
    }
    
    add_filter( 'wp_all_import_is_post_to_create', 'my_is_post_to_create', 10, 2 );
Viewing 1 replies (of 1 total)
  • The topic ‘Detecting Duplicate Titles’ is closed to new replies.