title: How to Get WooCommerce Product Name with WP_Query?
body: <p>I am trying to use this code on &quot;Wp All Import&quot;. If there is a product name in the database, that product should be omitted, but the code will not work as is. What do I need to do for the code to work?</p>
  <pre><code>add_filter('wp_all_import_is_post_to_create', 'create_only_if_unique_custom_field', 10, 3);
  function create_only_if_unique_custom_field( $continue_import, $data, $import_id ) {
      // Only run for import ID 1.
      if ( $import_id == 33 || $import_id == 34 ) {
  
          // The custom field to check.
          $key_to_look_up = &quot;post_title&quot;;
  
          // The value to check where 'num' is the element name.
          $value_to_look_up = $data['name'];
  
          // Prepare the WP_Query arguments
          $args = array (
  
              // Set the post type being imported.
              'post_type'  =&gt; array( 'post' ),
  
              // Check our custom field for our value.
              'meta_query' =&gt; array(array(
              'key'        =&gt; $key_to_look_up,
              'value'      =&gt; $value_to_look_up,
              )),
          );
  
      // Run the query and do not create post if custom field value is duplicated.
      $query = new WP_Query( $args );
      return !($query-&gt;have_posts());
  
      } else {
  
         // Take no action if a different import ID is running.
         return $continue_import;
  
      }
  }
  </code></pre>