record matching wp all import

Mastering Record Matching in WP All Import

When it comes to efficiently managing and updating WordPress content, WP All Import is an indispensable tool for developers and site administrators alike. With its versatile features and robust capabilities, one aspect that stands out for power users is the ability to master record matching. In this comprehensive guide, we will delve into the intricacies of record matching using custom PHP functions, explore real-world use cases, and demonstrate how to leverage this functionality to optimize your WordPress workflow.

Understanding Record Matching

Before we delve into the technical aspects, let’s grasp the concept of record matching in WP All Import. At its core, record matching is the process of identifying and updating existing WordPress posts by matching specific criteria, such as post slugs, from an external data source – most commonly, a CSV file. This allows us to avoid creating duplicate posts and ensure seamless updates to our content.

In this tutorial, we’ll focus on matching posts based on their slugs, which serve as unique identifiers in WordPress. By employing custom PHP functions, we can efficiently match slugs from our CSV data to their corresponding post IDs in WordPress, enabling smooth updates with WP All Import.

The Power of Custom PHP Functions

To achieve record-matching nirvana, we’ll first create a custom PHP function tailored to our needs. This function will take the post slug as input and return the corresponding Post ID. We can then use this Post ID to update the relevant post, making it a vital piece of our record-matching puzzle.

Let’s take a look at the custom PHP function that performs the magic:

// Create custom PHP function that we can use in the "Post ID" field under Record Matching
// We pass the post slug to our function, then we use this function to look up the post by its slug and return the Post ID
function fs_get_post_by_slug( $slug, $post_type = 'post' ) {
    if ( $post = get_page_by_path( $slug, OBJECT, $post_type ) ) {
        return $post->ID;

The function fs_get_post_by_slug() takes two parameters: $slug and $post_type. By default, it queries the ‘post’ post type, but you can specify a custom post type using the $post_type parameter.

You should save this function in the Function Editor area like this:

wp all import functions

Practical Usage of the Custom Function

Now that we have our custom PHP function in place, let’s explore how we can use it in WP All Import. In the “Post ID” field of WP All Import, we can directly call our function to match the post slugs from the CSV data. Here’s an example of how it’s done:


Note that {postslug[1]} represents the column name (node/tag) in the CSV file where your post slugs are located. Replace it with the appropriate column name you have in your data source, such as {slug[1]}.

In case you are dealing with a custom post type, you can modify the function call to include the post type slug as the second parameter, like this:


This way, the function will look for the slug in the custom post type ‘product’, allowing you to handle various post types seamlessly.

Leveraging Advanced Custom Fields (ACF)

The true power of record matching shines when combined with Advanced Custom Fields (ACF). ACF offers a robust framework for creating custom fields and metadata, enhancing the flexibility of your WordPress content. We can use ACF fields alongside our custom PHP function to generate slugs and then query the Post ID based on those slugs.

This will be useful in case you have used columns to generate the slug when importing posts in the very first place. For example, let’s say you have gathered some data from Amazon, then tried to import the products, and you’ve set the slug of the products by combining the columns such as product_title, product_release_date and product_variant.

We generate a function called post_slug which it takes some inputs and then returns a string (slug):

function post_slug( $product_title, $product_release_date, $product_variant  ) {
	$slug = "";
	if ( !empty( $product_title ) ) {
		$slug .= $product_title;
	if ( !empty( $product_release_date ) ) {
		$slug .= "-" . $product_release_date . "-";
	if ( !empty( $product_variant ) ) {
		$slug .= "-" . $product_variant ;
	$string = str_replace(' ', '-', $slug); // Replaces all spaces with hyphens.
   	$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.

   return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.

Let’s explore an example where we have an ACF field that contains the desired slug. We’ll then use this ACF field to generate the Post ID:

[fs_get_post_by_slug(post_slug({title[1]}, {release_date[1]}, {variant[1]}))]

In this scenario, we retrieve the slug from the ACF fields. We then pass this slug as an argument to our custom PHP function, fs_get_post_by_slug(), which returns the corresponding Post ID.

This combination of WP All Import’s record matching, custom PHP functions, and ACF opens up a world of possibilities for automating complex updates and ensuring your content is always up-to-date.

Real-World Use Cases

Now that we’ve covered the technical aspects, let’s explore some real-world use cases where mastering record matching in WP All Import can save time and streamline your WordPress workflow:

1. Product Catalog Updates

For e-commerce websites, product catalogs often need regular updates. By using WP All Import’s record matching, you can effortlessly synchronize your product data with an external data source. Whether it’s price adjustments, stock levels, or product descriptions, record matching ensures that your product database stays accurate and up-to-date.

2. Events and Timetables

Managing event schedules and timetables is a breeze with record matching. Keep your event listings current by matching event names or dates from an external schedule CSV. This way, your users will always have access to the latest event information.

3. Real Estate Listings

Real estate websites frequently require updates to property listings. WP All Import’s record matching enables you to update property details, images, and other critical information with ease. Say goodbye to manual updates and embrace the efficiency of automation.

4. News and Blog Articles

For news portals and blogs, keeping articles fresh is essential. Record matching allows you to update article titles, content, and publication dates seamlessly. Your audience will appreciate the accuracy and relevancy of your content.


In this in-depth guide, we’ve explored the powerful world of record matching in WP All Import. We’ve created a custom PHP function, leveraged ACF fields, and examined real-world use cases to demonstrate how this feature can significantly enhance your WordPress content management.

By mastering record matching, you can streamline your content updates, improve data accuracy, and save valuable time. WP All Import becomes your ally in managing dynamic websites, providing a seamless experience for both administrators and end-users.

So, why wait? Take control of your WordPress content updates with record matching in WP All Import and elevate your website to new heights of efficiency and reliability.