{"id":2991646,"date":"2019-11-14T00:00:00","date_gmt":"2019-11-14T00:00:00","guid":{"rendered":"http:\/\/www.wpallimport.com\/documentation\/developers\/code-snippets\/"},"modified":"2025-12-18T16:11:14","modified_gmt":"2025-12-18T16:11:14","slug":"code-snippets","status":"publish","type":"documentation","link":"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/","title":{"rendered":"Example Code To Simplify Your Imports and Exports"},"content":{"rendered":"\n<p>These snippets cover the more common cases where custom code is necessary during import. Unique plugin or theme requirements often necessitate such code. It can also be due to odd import file formats that aren't fully compatible with WP All Import or WP All Export on their own. You would place these snippets in WP All Import's or WP All Export's Function Editor.<\/p>\n\n\n\n<p><a href=\"\/documentation\/custom-code-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\">Click here for more information<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<p><strong>For Imports<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#trigger-the-next-import-on-completion-of-an-import\">Trigger the Next Import on Completion of an Import<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-get-the-post-type-being-imported\">Retrieve Post Type of Current Import<\/a><\/li>\n\n\n\n<li><a href=\"#price-markup-with-minimum-advertised-price-and-msrp-limits\">Markup Price with Minimum and Maximum Limits<\/a><\/li>\n\n\n\n<li><a href=\"#reduce-stock-levels-for-imported-order-items\">Reduce Stock for Imported Order Items<\/a><\/li>\n\n\n\n<li><a href=\"#enable-rapid-add-on-api-sections-for-user-or-customer-import\">Enable Rapid Add-On API Sections for User or Customer Import<\/a><\/li>\n\n\n\n<li><a href=\"#workaround-for-importing-from-ftp\">Workaround for Importing from FTP<\/a><\/li>\n\n\n\n<li><a href=\"#reference-taxonomy-terms-by-custom-id\">Reference Taxonomy Terms by Custom ID<\/a><\/li>\n\n\n\n<li><a href=\"#find-file-elements-that-start-with-certain-text\">Find File Elements That Start with Certain Text<\/a><\/li>\n\n\n\n<li><a href=\"#mapping-values\">Map File Values During Import<\/a><\/li>\n\n\n\n<li><a href=\"#send-email-after-import-is-complete\">Send Email After Import is Complete<\/a><\/li>\n\n\n\n<li><a href=\"#check-the-number-of-posts-imported\">Count Number of Created Posts<\/a><\/li>\n\n\n\n<li><a href=\"#only-import-existing-categories-or-other-taxonomy-terms\">Only Import Existing Taxonomy Terms<\/a><\/li>\n\n\n\n<li><a href=\"#keep-certain-categories-assigned-even-if-they-do-not-appear-in-your-import-file\">Do Not Remove Certain Categories During Import<\/a><\/li>\n\n\n\n<li><a href=\"#apply-wp_handle_upload-filter-to-uploaded-attachments-and-filters\">Apply wp_handle_upload Filter to Uploaded Files<\/a><\/li>\n\n\n\n<li><a href=\"#add-password-to-imported-post\">Set Password for Imported Posts<\/a><\/li>\n\n\n\n<li><a href=\"#use-import-id-in-the-import-template\">Retrieve Import ID for Use in Template<\/a><\/li>\n\n\n\n<li><a href=\"#generate-taxonomy-hierarchy-using-child-taxonomies\">Generate Taxonomy Hierarchy from Child Terms<\/a><\/li>\n\n\n\n<li><a href=\"#split-by-index\">Split String at Delimiter and Return One Value<\/a><\/li>\n\n\n\n<li><a href=\"#pull-url-from-a-string\">Retrieve URL from String<\/a><\/li>\n\n\n\n<li><a href=\"#generate-dynamic-import-url\">Generate Dynamic Import URL<\/a><\/li>\n\n\n\n<li><a href=\"#use-xpath-query-based-on-cyrillic-attribute-value\">Use XPath Query Based on Cyrillic Attribute Value<\/a><\/li>\n\n\n\n<li><a href=\"#assign-a-post-parent-programmatically\">Assign A Post Parent Programmatically<\/a><\/li>\n\n\n\n<li><a href=\"#get-post-id-by-custom-field\">Get Post ID By Custom Field<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>For Exports<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#export-total-number-of-sales-for-variations\">Export Total Number of Sales for Variations<\/a><\/li>\n\n\n\n<li><a href=\"#get-parent-attributes-when-exporting-variations-to-google-merchant-center\">Get Parent Attributes When Exporting Variations to Google Merchant Center<\/a><\/li>\n\n\n\n<li><a href=\"#export-parent-sku-when-variation-sku-is-blank\">Export Parent SKU When Variation SKU is Blank<\/a><\/li>\n\n\n\n<li><a href=\"#send-export-file-via-email\">Send Export File via Email<\/a><\/li>\n\n\n\n<li><a href=\"#export-toolset-relationship-fields\">Export Toolset Relationship Fields<\/a><\/li>\n\n\n\n<li><a href=\"#filter-export-data-with-multiple-filters\">Filter Export Data with Multiple Filters<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Custom Fields<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#conditionally-delete-a-custom-field-based-on-the-value-of-a-different-field\">Delete a Custom Field If Another Field Has a Specific Value<\/a><\/li>\n\n\n\n<li><a href=\"#enable-custom-fields-meta-box-on-post-admin\">Enable Custom Fields Section in Post Admin<\/a><\/li>\n\n\n\n<li><a href=\"#append-data-to-a-custom-field-instead-of-replacing-it\">Append Data to a Custom Field Instead of Overwriting<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-custom-field-if-another-field-has-a-certain-value\">Update Second Custom Field If First Field Has Specified Value<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-custom-field-if-new-value-is-not-empty\">Only Update Custom Field If New Value is Not Empty<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-custom-field-if-its-currently-empty\">Only Update Custom Field If It's Currently Empty<\/a><\/li>\n\n\n\n<li><a href=\"#find-post-by-custom-field-value\">Find Post by Custom Field Value<\/a><\/li>\n\n\n\n<li><a href=\"#only-create-a-post-if-an-existing-post-doesnt-have-the-same-custom-field-value\">Only Create Post If Custom Field Value is Unique<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Images and Galleries:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#import-wp-user-avatar-image-when-importing-users-or-customers\">Import Images to WP User Avatar Plugin<\/a><\/li>\n\n\n\n<li><a href=\"#include-featured-image-in-product-gallery-also\">Include Featured Image in Product Gallery<\/a><\/li>\n\n\n\n<li><a href=\"#save-images-to-your-themes-or-plugins-custom-gallery\">Save Images to Your Theme's or Plugin's Custom Gallery<\/a><\/li>\n\n\n\n<li><a href=\"#save-imported-images-to-a-custom-folder\">Save Imported Images to a Custom Folder<\/a><\/li>\n\n\n\n<li><a href=\"#image-for-property-themes\">Bulk Attach Images to a Record's Custom Gallery<\/a><\/li>\n\n\n\n<li><a href=\"#prepend-url-to-multiple-images-in-a-single-element\">Prepend URL to Multiple Images in a Single Element<\/a><\/li>\n\n\n\n<li><a href=\"#save-imported-images-to-a-folder-based-on-the-post-date\">Save Imported Images to a Folder Based on the Post Date<\/a><\/li>\n\n\n\n<li><a href=\"#store-images-using-sources-path\">Store Images Using Source's Path<\/a><\/li>\n\n\n\n<li><a href=\"#use-the-second-image-if-the-first-image-is-not-valid\">Use the Second Image if the First Image Is Not Valid<\/a><\/li>\n\n\n\n<li><a href=\"#programmatically-remove-imported-images-that-are-no-longer-available\">Programmatically Remove Imported Images That Are No Longer Available<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>WooCommerce<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#create-one-variation-of-any-for-variable-product\">List One 'Any Attribute' Variation for Variable Products<\/a><\/li>\n\n\n\n<li><a href=\"#fix-missing-options-in-the-attributes-dropdown-for-variable-products\">Variations Not Updating When Selected on Frontend<\/a><\/li>\n\n\n\n<li><a href=\"#custom-items-loop-for-woocommerce-orders-exports\">Custom Items Loop for WooCommerce Orders Exports<\/a><\/li>\n\n\n\n<li><a href=\"#use-parent-prices-for-variations\">Use Parent Prices for Variations<\/a><\/li>\n\n\n\n<li><a href=\"#match-by-sku-when-the-skus-on-your-site-contain-extra-characters\">Match By SKU When The SKUs on Your Site Contain Extra Characters<\/a><\/li>\n\n\n\n<li><a href=\"#do-not-create-products-with-duplicate-sku\">Do Not Create Products With Duplicate SKU<\/a><\/li>\n\n\n\n<li><a href=\"#price-rounding\">Round Imported Prices<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-increase-stock-instead-of-replacing-it\">How to Increase Stock Instead of Replacing It<\/a><\/li>\n\n\n\n<li><a href=\"#query-orders-by-old-id\">Query Orders by Old ID<\/a><\/li>\n\n\n\n<li><a href=\"#import-grouped-products\">Import Grouped Products<\/a><\/li>\n\n\n\n<li><a href=\"#adjust-prices-based-on-the-price-range\">Adjust Prices Based on The Price Range<\/a><\/li>\n\n\n\n<li><a href=\"#update-variable-products-stock-and-price-by-title\">Update Variable Products Stock and Price by Title<\/a><\/li>\n\n\n\n<li><a href=\"#if-no-variation-image-export-parent-image-as-fallback\">If No Variation Image, Export Parent Image as Fallback<\/a><\/li>\n\n\n\n<li><a href=\"#calculate-order-totals-based-on-product-price\">Calculate Order Totals Based on Product Price<\/a><\/li>\n\n\n\n<li><a href=\"#use-existing-variation-prices-for-variations-without-price\">Use Existing Variation Prices for Variations without Price<\/a><\/li>\n\n\n\n<li><a href=\"#add-data-into-custom-fields-for-variations-using-child-xml-import-option\">Add Data into Custom Fields for Variations Using Child XML Import Option<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Miscellaneous<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#curl-error-60\">cURL Error 60<\/a><\/li>\n\n\n\n<li><a href=\"#import-multisite-users\">Import Multisite Users to Multiple Subsites<\/a><\/li>\n\n\n\n<li><a href=\"#add-a-custom-message-to-the-history-log\">Add Entry to the Import Log<\/a><\/li>\n\n\n\n<li><a href=\"#import-users-with-the-same-email\">Import Users With The Same Email<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Theme and Plugin Integrations:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#houzez-linking-neighborhoods-cities-states-and-countries\">Houzez - Linking Neighborhoods, Cities, States, and Countries<\/a><\/li>\n\n\n\n<li><a href=\"#flatsome-theme-taxonomy-top-and-bottom-content\">Flatsome Theme - Taxonomy Top and Bottom Content<\/a><\/li>\n\n\n\n<li><a href=\"#import-suppliers-to-the-atum-inventory-management-plugin\">Import Suppliers to the ATUM Inventory Management for WooCommerce plugin<\/a><\/li>\n\n\n\n<li><a href=\"#import-barcodes-to-the-atum-inventory-management-plugin\">Import Barcodes to the ATUM Inventory Management for WooCommerce plugin<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Data Manipulation for Imports:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#append-acf-repeater-data\">Append ACF Repeater Data<\/a><\/li>\n\n\n\n<li><a href=\"#only-continue-import-if-import-file-contains-records\">Cancel Import If File Empty<\/a><\/li>\n\n\n\n<li><a href=\"#delete-import-file-after-import\">Delete Source File After Import<\/a><\/li>\n\n\n\n<li><a href=\"#manually-set-import-file-type\">Manually Set Import Feed Type<\/a><\/li>\n\n\n\n<li><a href=\"#combine-html-elements-in-xml-without-cdata-tags\">Combine HTML Elements In XML Without CDATA Tags<\/a><\/li>\n\n\n\n<li><a href=\"#add-elements-to-xml-on-the-fly\">Modify Record Before It's Imported<\/a><\/li>\n\n\n\n<li><a href=\"#access-data-above-element-chosen-on-step-2\">Access Data Outside of Element Chosen on Step 2<\/a><\/li>\n\n\n\n<li><a href=\"#convert-features-with-0-and-1-values-to-comma-delimited-list\">Map Values to Element Name Based on Value<\/a><\/li>\n\n\n\n<li><a href=\"#import-acf-post2post-plugin-bidirectional-fields\">Import ACF Post2Post Plugin Bidirectional Fields<\/a><\/li>\n\n\n\n<li><a href=\"#import-data-to-custom-database-table-during-record-import\">Import Data to Custom Database Table<\/a><\/li>\n\n\n\n<li><a href=\"#change-delimiter-used-when-retrieving-multiple-elements-with-xpath\">Use Custom Delimiter When Retrieving Multiple Values<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-acf-field-value-if-imported-value-is-not-empty\">Only Update ACF Fields If Imported Values Are Not Empty<\/a><\/li>\n\n\n\n<li><a href=\"#filter-posts-by-date\">Filter Posts by Date<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-posts-that-are-set-as-draft\">Only Update Posts with a Specific Status<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-products-with-a-different-stock-status-in-the-import-file\">Only Update Products If the Stock Status Changed<\/a><\/li>\n\n\n\n<li><a href=\"#only-update-product-if-price-was-not-manually-changed\">Only Update Product If Price Was Not Manually Changed<\/a><\/li>\n\n\n\n<li><a href=\"#delete-orphaned-variations-when-deleting-parent-product\">Delete Orphaned Variations When Deleting Previously Imported Products<\/a><\/li>\n\n\n\n<li><a href=\"#prevent-some-posts-from-being-deleted-by-wp-all-import\">Prevent Some Posts From Being Deleted by WP All Import<\/a><\/li>\n\n\n\n<li><a href=\"#comma-separated-data-to-serialized-array\">Convert Comma-separated List into Serialized Array<\/a><\/li>\n\n\n\n<li><a href=\"#merge-multiple-xml-files\">Merge Multiple XML Files<\/a><\/li>\n\n\n\n<li><a href=\"#keep-old-ids-when-migrating-products\">Keep Old IDs When Migrating Products or Posts<\/a><\/li>\n\n\n\n<li><a href=\"#keep-old-ids-when-migrating-users-or-customers\">Keep Old IDs When Migrating Users or Customers<\/a><\/li>\n\n\n\n<li><a href=\"#keep-old-ids-when-migrating-categories-and-other-taxonomy-terms\">Keep Old IDs When Migrating Categories and Other Taxonomy Terms<\/a><\/li>\n\n\n\n<li><a href=\"#keep-old-ids-when-migrating-comments\">Keep Old IDs When Migrating Comments<\/a><\/li>\n\n\n\n<li><a href=\"#change-uploads-folder-during-import\">Change Uploads Folder During Import<\/a><\/li>\n\n\n\n<li><a href=\"#extract-url-from-a-string\">Extract URL From a String<\/a><\/li>\n\n\n\n<li><a href=\"#limit-depth-of-categories\">Limit the Depth of Categories<\/a><\/li>\n\n\n\n<li><a href=\"#update-only-selected-records\">Prevent Certain Records from Being Updated<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-import-jetengine-relations\">How to Import JetEngine Relations<\/a><\/li>\n<\/ul>\n\n\n\n<p><strong>Data Manipulation for Exports:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#send-export-file-to-ftp-destination\">Send Export File to FTP Destination<\/a><\/li>\n\n\n\n<li><a href=\"#set-order-to-complete-after-order-is-exported\">Set Exported Order Status<\/a><\/li>\n\n\n\n<li><a href=\"#dont-export-variations-to-gmc-when-parent-set-to-draft\">Filter Variations by Parent Status When Exporting to GMC<\/a><\/li>\n\n\n\n<li><a href=\"#only-export-records-to-csv-based-on-date\">Limit Records Exported to CSV by Date<\/a><\/li>\n\n\n\n<li><a href=\"#limit-number-of-records-exported-when-exporting-to-xml\">Limit Number of Records Exported When Exporting to XML<\/a><\/li>\n\n\n\n<li><a href=\"#add-custom-line-endings-to-csv-export-file\">Append Custom Line Endings to Export File<\/a><\/li>\n\n\n\n<li><a href=\"#programmatically-add-elements-to-xml-exports\">Programmatically Add Elements to XML Exports<\/a><\/li>\n\n\n\n<li><a href=\"#move-export-file-after-export\">Move Generated File After Export<\/a><\/li>\n\n\n\n<li><a href=\"#run-cron-export-with-only-a-trigger-cron-job\">Run Cron Export with Only a Trigger Cron Job and 1 Processing Cron Job<\/a><\/li>\n\n\n\n<li><a href=\"#export-data-from-custom-database-tables\">Export Data From Custom Database Tables<\/a><\/li>\n\n\n\n<li><a href=\"#export-acf-nested-repeaters\">Export ACF Nested Repeaters<\/a><\/li>\n\n\n\n<li><a href=\"#how-to-export-jetengine-relations\">How to Export JetEngine Relations<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n<div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#conditionally-delete-a-custom-field-based-on-the-value-of-a-different-field\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"conditionally-delete-a-custom-field-based-on-the-value-of-a-different-field\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#conditionally-delete-a-custom-field-based-on-the-value-of-a-different-field\" class=\"snippet-title\"><h2><strong>Delete a Custom Field If Another Field Has a Specific Value<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\">pmxi_saved_post<\/a><\/code> action, <code><a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\">get_post_meta()<\/a><\/code>, and <code><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/delete_post_meta\/\" target=\"_blank\">delete_post_meta()<\/a><\/code> to delete <code>_my_custom_field<\/code> if <code>_my_update_check<\/code> is set to 'yes'.  <\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function conditional_delete( $id ) {\n\n    \/\/ Retrieve check field's value.\n    $check = get_post_meta( $id, '_my_delete_check', true );\n\n    if ( $check === 'yes' ) {\n\n        \/\/ If check value is 'yes' delete _my_field.\n        delete_post_meta( $id, '_my_field' );\n\n    }\n}\nadd_action( 'pmxi_saved_post', 'conditional_delete', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#price-markup-with-minimum-advertised-price-and-msrp-limits\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"price-markup-with-minimum-advertised-price-and-msrp-limits\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#price-markup-with-minimum-advertised-price-and-msrp-limits\" class=\"snippet-title\"><h2><strong>Markup Price with Minimum and Maximum Limits<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we clean up the price in our file, add a markup, and ensure it's within our required minimum and maximum prices.  The <code>$price<\/code> and <code>$multiplier<\/code> parameters are required.  The others are optional and can be used to further customize the final price:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>Parameter<\/td><td>Description<\/td><\/tr><tr><td>$price<br><\/td><td>The original price.<\/td><\/tr><tr><td>$multiplier<\/td><td>Multiply the original price by this number.<\/td><\/tr><tr><td>$nearest<\/td><td>Round to the nearest value (0.01 by default).<\/td><\/tr><tr><td>$minus<\/td><td>Subtract this value from the rounded price.<\/td><\/tr><tr><td>$map<\/td><td>The minimum price that can be returned.<\/td><\/tr><tr><td>$msrp<\/td><td>The maximum price that can be returned.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We call the function from any field that needs a marked up price:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-03-at-19.43.38-1024x467.png\" alt=\"\" class=\"wp-image-1464\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function round_price_with_limits( $price = null, $multiplier = 1, $nearest = .01, $minus = 0, $map = 0, $msrp = 9999999999) {\n\n    \/\/ Ensure a price was provided.\n    if ( !empty( $price ) ) {\n\n        \/\/ Remove unwanted characters from price.\n        $price = preg_replace(\"\/[^0-9,.]\/\", \"\", $price);\n\n        \/\/ Remove unwanted characters from min price.\n        $map = preg_replace(\"\/[^0-9,.]\/\", \"\", $map);\n\n        \/\/ Remove unwanted characters from max price.\n        $msrp = preg_replace(\"\/[^0-9,.]\/\", \"\", $msrp);\n\n        \/\/ Calculate price with markup and round it.\n        $rounded_price = ( round ( ( $price * $multiplier ) \/ $nearest ) * $nearest ) - $minus; \n\n        \/\/ If price is less than minimum, return minimum.\n        if($rounded_price &lt; $map){\n\n            return $map;\n\n        }\n        \/\/ If price is greater than maximum, return maximum.\n        elseif($rounded_price &gt; $msrp){\n\n            return $msrp;\n\n        } else {\n\n            \/\/ Return price otherwise.\n            return $rounded_price;\n\n        }\n\n    }\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#trigger-the-next-import-on-completion-of-an-import\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"trigger-the-next-import-on-completion-of-an-import\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#trigger-the-next-import-on-completion-of-an-import\" class=\"snippet-title\"><h2><strong>Trigger the next Import on Completion of an Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_after_xml_import\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_after_xml_import (opens in a new tab)\">pmxi_after_xml_import<\/a><\/code> action to redirect the connection to the next import's 'trigger' URL.  We are able to ensure the first import will always complete before the next is started.  This is especially helpful when our second import depends on data provided by the first.<\/p>\n\n\n\n<p>All imports still require the <a rel=\"noreferrer noopener\" aria-label=\"'processing' cron jobs (opens in a new tab)\" href=\"\/documentation\/recurring\/cron\/\" target=\"_blank\">'processing' cron jobs<\/a> or they won't run.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function after_xml_import($import_id, $import) {\n    \n\t\/\/ Only run for import ID 5.\n\tif ($import_id == 5) {\n\n\t\t\/\/ Call the next import's trigger URL.\n\t\twp_remote_get(\"yourtriggerURLhere\");\n    }\n}\nadd_action('pmxi_after_xml_import', 'after_xml_import', 10, 2);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#reduce-stock-levels-for-imported-order-items\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"reduce-stock-levels-for-imported-order-items\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#reduce-stock-levels-for-imported-order-items\" class=\"snippet-title\"><h2><strong>Reduce Stock for Imported Order Items<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\"pmxi_saved_post (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_saved_post<\/a><\/code> action and <code><a href=\"https:\/\/woocommerce.github.io\/code-reference\/namespaces\/default.html#function_wc_reduce_stock_levels\" target=\"_blank\" rel=\"noreferrer noopener\">wc_reduce_stock_levels<\/a><\/code><a href=\"https:\/\/woocommerce.github.io\/code-reference\/namespaces\/default.html#function_wc_reduce_stock_levels\" target=\"_blank\" rel=\"noreferrer noopener\"><code>()<\/code><\/a> to deduct ordered items from product stock. This is necessary since WP All Import doesn't touch product stock when importing Orders by default.    <\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function decrease_order_item_stock($post_id, $xml_node, $is_update) {\n\n&nbsp; &nbsp; \/\/ Retrieve the import ID.&nbsp;\n    $import_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['import_id'] ) ? $_GET['import_id'] : 'new' ) );\n\n    \/\/ Only run for imports 899, 898, and 895.\n    if ( in_array( $import_id, [899, 898, 895] ) ) {\n\n        \/\/ Decrease stock for order items if it hasn't already\n        \/\/ been decreased.\n        wc_reduce_stock_levels( $post_id );\n\n&nbsp; &nbsp; &nbsp;}\n}\nadd_action('pmxi_saved_post', 'decrease_order_item_stock', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-multisite-users\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-multisite-users\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-multisite-users\" class=\"snippet-title\"><h2><strong>Import Multisite Users to Multiple Subsites<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use our <a href=\"\/documentation\/custom-fields\/theme-plugin-fields\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Custom Fields (opens in a new tab)\">Custom Fields<\/a> capability to assign Users to more than one subsite on WordPress Multisite. This workaround is required due to the way Multisite stores Users.<\/p>\n\n\n\n<p>Custom fields are used to identify which subsite each User is authorized to use. Our example Multisite install uses the prefixes below for each subsite:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>wp_ <br>wp_2_ <br>wp_3_<\/code><\/p><\/blockquote>\n\n\n\n<p>A user must have these three Custom Fields defined to be authorized on all of our subsites:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>wp_capabilities <br>wp_2_capabilities <br>wp_3_capabilities<\/code><\/p><\/blockquote>\n\n\n\n<p>Each field must contain a serialized array of <a href=\"https:\/\/wordpress.org\/support\/article\/roles-and-capabilities\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"User Roles (opens in a new tab)\">User Roles<\/a>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><code>a:1:{s:10:\"subscriber\";b:1;}<\/code><\/p><\/blockquote>\n\n\n\n<p>For example:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/serialized_field.png\" alt=\"\" class=\"wp-image-1240\"\/><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#get-parent-attributes-when-exporting-variations-to-google-merchant-center\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"get-parent-attributes-when-exporting-variations-to-google-merchant-center\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#get-parent-attributes-when-exporting-variations-to-google-merchant-center\" class=\"snippet-title\"><h2><strong>Get Parent Attributes When Exporting Variations to Google Merchant Center<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use <code><a href=\"https:\/\/woocommerce.github.io\/code-reference\/namespaces\/default.html#function_wc_get_product\" target=\"_blank\" rel=\"noreferrer noopener\">wc_get_product<\/a><\/code> to retrieve the <a href=\"https:\/\/woocommerce.github.io\/code-reference\/classes\/WC-Product.html\" target=\"_blank\" rel=\"noreferrer noopener\"><code>WC_Product<\/code><\/a> object for each exported record.  This lets us retrieve attributes that are directly assigned to the parent products.  By default, when exporting to GMC only the attributes attached to the variations themselves are exported.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">\/\/ $attr must be the name of the attribute to be retrieved.\nfunction my_get_parent_attr( $id, $attr ){\n\n    \/\/ Get product object.\n    $prod = wc_get_product( $id );\n\n    \/\/ Check product type.\n    if( $prod-&gt;is_type('variation') ){\n\n        \/\/ Retrieve parent product's ID.\n        $parent = wc_get_product( $prod-&gt;get_parent_id() );\n\n        \/\/ Return parent's attribute value.\n        return $parent-&gt;get_attribute($attr);\n\n    } else {\n\n        \/\/ Return attribute value for simple products.\n        return $prod-&gt;get_attribute($attr);\n\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>Here it is in use:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-10-14-at-21.44.59.png\" alt=\"\" class=\"wp-image-1243\"\/><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#enable-rapid-add-on-api-sections-for-user-or-customer-import\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"enable-rapid-add-on-api-sections-for-user-or-customer-import\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#enable-rapid-add-on-api-sections-for-user-or-customer-import\" class=\"snippet-title\"><h2><strong>Enable Rapid Add-On API Sections for User or Customer Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_visible_template_sections\" target=\"_blank\">pmxi_visible_template_sections<\/a><\/code> filter to display our add-ons section. This allows it to show up for Users and Customers. We use the <code><a rel=\"noreferrer noopener\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_images_section_enabled\" target=\"_blank\">wp_all_import_is_images_section_enabled<\/a><\/code> filter to hide the Images section as it's not normally displayed for Users and Customers.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">\/\/ Enable our custom add-on's section.\nfunction show_addon_section_users_customers( $sections, $post_type ) {\n\n    \/\/ Enable add-on section for Users.\n    if ( 'import_users' == $post_type ) \n        $sections[] = 'featured';\n\n    \/\/ Enable add-on section for Customers.\n    if ( 'shop_customer' == $post_type ) \n        $sections[] = 'featured';\n\n    return $sections;\n}\nadd_filter( 'pmxi_visible_template_sections', 'show_addon_section_users_customers', 11, 2 );\n\n\/\/ Disable the Images section.\nfunction hide_images_users_customers( $is_enabled, $post_type ){\n\n    \/\/ Disable Images section for Users, return true to enable.\n    if ( 'import_users' == $post_type )       \n        $is_enabled = false;\n\n    \/\/ Disable Images section for Customers, return true to enable.\n    if ( 'shop_customer' == $post_type )       \n        $is_enabled = false;\n    \n    return $is_enabled;\n\n}\nadd_filter( 'wp_all_import_is_images_section_enabled', 'hide_images_users_customers', 10, 2 );<\/code><\/pre><\/div>\n\n\n\n<p>And, here's what the run() function would look like:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">$wp_user_avatar_addon-&gt;run(\n\tarray(\n        \"post_types\" =&gt; array( \"import_users\", \"shop_customer\" )\n\t)\n);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#export-total-number-of-sales-for-variations\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"export-total-number-of-sales-for-variations\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#export-total-number-of-sales-for-variations\" class=\"snippet-title\"><h2><strong>Export Total Number of Sales for Variations<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we export the total sales for each of our variations using some custom code. We need this workaround because WooCommerce doesn't track total sales at the variation level.<\/p>\n\n\n\n<p>We call it like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-11-at-20.28.05-928x1024.png\" alt=\"\" class=\"wp-image-1610\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_get_total_sales( $id ) {\n\n    \/\/ Only use database calls for variation counts.\n    if ( get_post_type( $id ) === 'product_variation' ) {\n        global $wpdb;\n        $table = $wpdb-&gt;prefix . 'woocommerce_order_itemmeta';\n        $count = array();\n        $total_count = 0;\n        $itemmeta = $wpdb-&gt;get_results( \"SELECT `order_item_id` FROM `$table` WHERE `meta_key` = '_variation_id' AND `meta_value` = '$id'\" );\n\n        \/\/ Ensure item meta was returned.\n        if ( ! empty( $itemmeta ) ) {\n\n            \/\/ Process each item.\n            foreach ( $itemmeta as $result ) {\n\n                \/\/ Ensure the order quantity was retrieved.\n                if ( $qty = $wpdb-&gt;get_row( \"SELECT `meta_value` FROM `$table` WHERE `meta_key` = '_qty' AND `order_item_id` = '{$result-&gt;order_item_id}'\" ) ) {\n\n                \/\/ Save the quantity ordered.\n                $count[ $result-&gt;order_item_id ] = $qty-&gt;meta_value;\n\n                }\n            }\n\n            \/\/ Switch to order items table.\n            $table = $wpdb-&gt;prefix . 'woocommerce_order_items';\n\n            \/\/ Process each item meta record.\n            foreach ( $itemmeta as $item_obj ) {\n\n                \/\/ Retrieve Order ID for each ordered item.\n                $order_id_results = $wpdb-&gt;get_row( \"SELECT `order_id`,`order_item_id` FROM `$table` WHERE `order_item_id` = '{$item_obj-&gt;order_item_id}'\" );\n\n                \/\/ Only continue if order was returned.\n                if ( ! empty( $order_id_results ) ) {\n\n                    \/\/ Retrieve the order status.\n                    $status = get_post_status( $order_id_results-&gt;order_id );\n\n                    \/\/ Check if order is completed.\n                    if ( $status == 'wc-completed' ) {\n\n                        \/\/ If it was add that item's count to total. \n                        $total_count = $total_count + $count[ $item_obj-&gt;order_item_id ];\n\n                    }\n                }\n            }\n        }\n\n    \/\/ Return total sales for variation.\n    return $total_count;\n\n    } else {\n\n        \/\/ Get product object.\n        $product = wc_get_product( $id );\n\n        \/\/ If the product isn't varible, return total sales.\n        return $product-&gt;get_total_sales();\n\n   }\n}<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#workaround-for-importing-from-ftp\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"workaround-for-importing-from-ftp\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#workaround-for-importing-from-ftp\" class=\"snippet-title\"><h2><strong>Workaround for Importing from FTP<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we call a custom function in the 'Download from URL' field to import from FTP. The code must be placed outside of WP All Import's Function Editor - your theme's functions.php file is a good place. We make use of <a rel=\"noreferrer noopener\" aria-label=\"wp_upload_dir() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_upload_dir\/\" target=\"_blank\"><code>wp_upload_dir()<\/code><\/a> when saving the retrieved file. <\/p>\n\n\n\n<p>The file is saved in the uploads directory, it's up to you to take any security precautions you deem necessary.<\/p>\n\n\n\n<p>We call the function from the 'Download from URL' option on Step 1:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-09-at-9.39.51-PM-1024x423.png\" alt=\"\" class=\"wp-image-1249\"\/><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If your FTP requires a username and password, it would look something like this:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[custom_file_download(\"ftp:\/\/username:password@hostname.com\/full\/path\/to\/file.csv\",\"csv\")]<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Otherwise, you can omit that part:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[custom_file_download(\"http:\/\/example.com\/full\/path\/to\/file.csv\",\"csv\")]<\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function custom_file_download( $url, $type = 'xml' ) {\n   \n    \/\/ Set our default cURL options.\n    $ch = curl_init();\n    curl_setopt( $ch, CURLOPT_URL, $url );\n    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );\n    curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, \"GET\" );\n\n    \/* Optional: Set headers if needed.\n    *    $headers = array();\n    *    $headers[] = \"Accept-Language: de\";\n    *    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);\n    *\/\n\n    \/\/ Retrieve file from $url.\n    $result = curl_exec( $ch );\n\n    \/\/ Return error if cURL fails.\n    if ( curl_errno( $ch ) ) {\n        exit( 'Error:' . curl_error( $ch ) );\n    }\n    curl_close( $ch );\n\n    \/\/ Identify the upload directory path.\n    $uploads  = wp_upload_dir();\n\n    \/\/ Generate full file path and set extension to $type.\n    $filename = $uploads['basedir'] . '\/' . strtok( basename( $url ), \"?\" ) . '.' . $type;\n\n    \/\/ If the file exists locally, mark it for deletion.\n    if ( file_exists( $filename ) ) {\n        @unlink( $filename );\n    }\n\n    \/\/ Save the new file retrieved from FTP.\n    file_put_contents( $filename, $result );\n\n    \/\/ Return the URL to the newly created file.\n    return str_replace( $uploads['basedir'], $uploads['baseurl'], $filename );\n\n}<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#fix-missing-options-in-the-attributes-dropdown-for-variable-products\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"fix-missing-options-in-the-attributes-dropdown-for-variable-products\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#fix-missing-options-in-the-attributes-dropdown-for-variable-products\" class=\"snippet-title\"><h2><strong>Variations Not Updating When Selected on Frontend<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/woocommerce.github.io\/code-reference\/namespaces\/default.html#function_woocommerce_variable_add_to_cart\" target=\"_blank\" rel=\"noreferrer noopener\">woocommerce_ajax_variation_threshold<\/a><\/code> filter to enable 150 variations to be loaded via AJAX on the frontend. This enables the product options to update when selecting each attribute from the dropdown. By default, those updates only work for products with 30 or fewer variations and products with more only have the selected options validated when adding them to the cart.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_change_threshold( $amount, $product ) {\n\n    \/\/ The max number of variations to load via AJAX.\n    return 150;\n\n}\nadd_filter( 'woocommerce_ajax_variation_threshold', 'soflyy_change_threshold', 10, 2 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#how-to-get-the-post-type-being-imported\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"how-to-get-the-post-type-being-imported\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#how-to-get-the-post-type-being-imported\" class=\"snippet-title\"><h2><strong>Retrieve Post Type of Current Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_create\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_create (opens in a new tab)\">wp_all_import_is_post_to_create<\/a><\/code> filter to retrieve the Post Type being imported.  This code works with any of our hooks.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function get_import_post_type($continue_import, $current_xml_node, $import_id){\n\n    \/\/ Retrieve import object.\n    $import = new PMXI_Import_Record();\n    $import-&gt;getById($import_id);\n\n    \/\/ Ensure import object is valid.\n    if ( ! $import-&gt;isEmpty() ) {\n\n        \/\/ Retrieve post type.\n        $post_type = $import-&gt;options['custom_type'];\n\n        \/\/ Use post type in your code.\n\n    }\n}\nadd_filter('wp_all_import_is_post_to_create', 'get_import_post_type', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#houzez-linking-neighborhoods-cities-states-and-countries\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"houzez-linking-neighborhoods-cities-states-and-countries\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#houzez-linking-neighborhoods-cities-states-and-countries\" class=\"snippet-title\"><h2><strong>Houzez - Linking Neighborhoods, Cities, States, and Countries<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\"pmxi_saved_post (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_saved_post<\/a><\/code> action to link Neighborhoods, Cities, and States for the Houzez theme. This is necessary because the <a href=\"https:\/\/favethemes.zendesk.com\/hc\/en-us\/articles\/360038456531-What-s-Included-In-My-Purchase-\" target=\"_blank\" rel=\"noreferrer noopener\">Houzez Add-On for WP All Import<\/a> doesn't handle it currently. You must use a <a aria-label=\"Taxonomies import (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"\/documentation\/taxonomies\/import-taxonomy-meta\/\" target=\"_blank\">Taxonomies import<\/a> for these examples.<\/p>\n\n\n\n<p>The neighborhoods are linked to cities by entries in the Options table. You'll need to set a 'parent_city' Custom Field:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-on-2018-09-20-at-16_08_04-1024x325.png\" alt=\"\" class=\"wp-image-1254\"\/><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Then add the code below to the Function Editor:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function link_houzez_city( $id, $xml, $is_update ) {\n\n    \/\/ Retrieve 'parent_city' and use it to find that City.\n    $term = get_term_by( \"name\", get_term_meta($id, \"parent_city\", true), \"property_city\" );\n\n    \/\/ Retrieve the City's slug.\n    $slug = $term-&gt;slug;\n    \n    \/\/ Generate the appropriate Option name.\n    $option_name = '_houzez_property_area_' . $id;\n    \n    \/\/ Set the option to link this Neighborhood to its City.\n    update_option($option_name, array(\"parent_city\"=&gt;$slug));\n\n}\nadd_action( 'pmxi_saved_post', 'link_houzez_city', 10, 3 );<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>When adding Cities to States you must set the 'parent_state' Custom Field ( instead of parent_city ):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function link_houzez_state( $id, $xml, $is_update ) {\n\n    \/\/ Retrieve 'parent_state' and use it to locate that State.\n    $term = get_term_by( \"name\", get_term_meta($id, \"parent_state\", true), \"property_state\" );\n\n    \/\/ Retrieve the State's slug.\n    $slug = $term-&gt;slug;\n    \n    \/\/ Generate the Option name.\n    $option_name = '_houzez_property_city_' . $id;\n    \n    \/\/ Set the Option to link the City and State.\n    update_option($option_name, array(\"parent_state\"=&gt;$slug));\n\n}\nadd_action( 'pmxi_saved_post', 'link_houzez_state', 10, 3 );<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>When adding States to Countries the Custom Field must be named 'parent_country' and must contain the 2 character Country Code ( e.g. US, CA, GB, IE, etc )<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function link_houzez_country( $id, $xml, $is_update ) {\n\n    \/\/ Retrieve 'parent_country' and use it as the slug.\n    $slug = get_term_meta($id, \"parent_country\", true);\n    \n    \/\/ Generate the Option name.\n    $option_name = '_houzez_property_state_' . $id;\n    \n    \/\/ Set the Option to link State and Country.\n    update_option($option_name, array(\"parent_country\"=&gt;$slug));\n\n}\nadd_action( 'pmxi_saved_post', 'link_houzez_country', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#flatsome-theme-taxonomy-top-and-bottom-content\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"flatsome-theme-taxonomy-top-and-bottom-content\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#flatsome-theme-taxonomy-top-and-bottom-content\" class=\"snippet-title\"><h2><strong>Flatsome Theme - Taxonomy Top and Bottom Content<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use a custom function to import data to the Top and Bottom Content fields of the Flatsome Theme. This is necessary due to the format required for those fields.<\/p>\n\n\n\n<p>The bottom content and top content are stored in a serialized array in the 'cat_meta' field. You must tell WPAI to update that field ( Manage Imports &gt; Import Settings ): <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Annotation-on-2018-4-1-1024x684.png\" alt=\"\" class=\"wp-image-1256\"\/><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Here's an example snippet to use in the Function Editor that accepts your Bottom and Top Content values as parameters. It returns the serialized array as required by Flatsome:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_term_meta( $bottomContent, $topContent = '' ) {\n\t\n\t$meta = array('cat_header' =&gt; $topContent, 'cat_footer' =&gt; $bottomContent);\n\treturn serialize($meta);\n\n}<\/code><\/pre><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Here's the code in action:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-at-May-21st-2018-12.52.59-pm@2.5x-1024x334.png\" alt=\"\" class=\"wp-image-1257\"\/><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#add-a-custom-message-to-the-history-log\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"add-a-custom-message-to-the-history-log\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#add-a-custom-message-to-the-history-log\" class=\"snippet-title\"><h2><strong>Add Entry to the Import Log<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we are using the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\">pmxi_saved_post<\/a><\/code> action to add an entry to the import log every time a post is successfully imported or updated. You can use a different action to add log entries at a different time, such as whenever an image is imported, or a custom field updated, etc.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_custom_log_entry($id) {     \n\t$logger = function($m) {printf(\"[%s] $m\", date(\"H:i:s\"));flush();};\n\n\t\/\/ Define your log entry here\n\tcall_user_func($logger, \"This is my log message.\"); \n\n}\nadd_action('pmxi_saved_post', 'my_custom_log_entry', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#reference-taxonomy-terms-by-custom-id\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"reference-taxonomy-terms-by-custom-id\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#reference-taxonomy-terms-by-custom-id\" class=\"snippet-title\"><h2><strong>Reference Taxonomy Terms by Custom ID<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use <a rel=\"noreferrer noopener\" aria-label=\"get_terms() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_terms\/\" target=\"_blank\"><code>get_terms()<\/code><\/a> to retrieve previously imported categories by the <code>_my_old_id<\/code> custom field. This is necessary when using import files that only reference categories by ID.  <\/p>\n\n\n\n<p>Here's an example category file:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>name<\/td><td>description<\/td><td>id_parent<\/td><td>id_category<\/td><\/tr><tr><td>Parent<\/td><td>An example parent category.<\/td><td><\/td><td>1<\/td><\/tr><tr><td>Child<\/td><td>An example child category.<\/td><td>1<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Here's an example product file:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>name<\/td><td>price<\/td><td>id_category_default<\/td><\/tr><tr><td>Apples<\/td><td>1.25<\/td><td>2<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We start with a <a rel=\"noreferrer noopener\" href=\"\/documentation\/taxonomies\/import-taxonomy-meta\/\" target=\"_blank\">Taxonomies &gt; Product Categories<\/a> import. On Step 3, we save our ID to a custom field named <code>_my_old_id<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/68747470733a2f2f636c2e6c792f3763316262323137633937612f496d61676525323532353230323031392d30332d32372532353235323061742532353235323031312e34372e323125323532353230504d2e706e67-1024x411.png\" alt=\"\" class=\"wp-image-1262\"\/><\/figure>\n\n\n\n<p>The code below is placed in the Function Editor:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_get_cat_slug( $old_id, $id = true ) {\n    $args = array(\n        'hide_empty' =&gt; false,\n\n        \/\/ Specify what field to search for the ID.\n        'meta_query' =&gt; array(\n            array(\n            'key'       =&gt; '_my_old_id',\n            'value'     =&gt; $old_id,\n            'compare'   =&gt; '='\n            )\n        )\n    );\n\n    \/\/ Search the Product Category taxonomy for our term.\n    $terms = get_terms( 'product_cat', $args );\n    \n    if( $id === true ){\n\n        \/\/ By default we return the term's WordPress ID.\n        return $terms[0]-&gt;term_id;\n\n    }else{\n\n        \/\/ If $id is false we return the term's slug instead.\n        return $terms[0]-&gt;slug;\t\n\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>Here we use our code to specify the Parent Term:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/68747470733a2f2f636c2e6c792f3234363861343365623330312f496d61676525323532353230323031392d30332d32372532353235323061742532353235323031312e35332e303225323532353230504d2e706e67-1024x342.png\" alt=\"\" class=\"wp-image-1263\"\/><\/figure>\n\n\n\n<p>If all Parent Terms are listed before their children in the file, the records per iteration can be set to 1 to ensure they're linked (Manage Imports &gt; Import Settings):<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/68747470733a2f2f636c2e6c792f3131353833613461656230622f496d61676525323532353230323031392d30332d32372532353235323061742532353235323031312e35372e323425323532353230504d2e706e67-1024x500.png\" alt=\"\" class=\"wp-image-1264\"\/><\/figure>\n\n\n\n<p>Otherwise, the import must be run twice to link the Parent Terms.<\/p>\n\n\n\n<p>Now the imported Product Category terms are available to use when importing our products. We need each term's slug so we set the second parameter to false when calling our code:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/68747470733a2f2f636c2e6c792f3136363537636131333830372f496d61676525323532353230323031392d30332d32382532353235323061742532353235323031322e31342e323825323532353230414d2e706e67-1024x541.png\" alt=\"\" class=\"wp-image-1265\"\/><\/figure>\n\n\n\n<p>If you need to reference multiple categories per record, you'll need some additional code in the Function Editor:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_get_multiple_slugs( $old_id, $id = true, $delimiter = ',' ){\n\t\n    \/\/ Split the category references on the given delimiter.\n    $values = explode($delimiter, $old_id);\n    \/\/ Declare a variable for our located categories.\n    $cat_list = [];\n\t\n    \/\/ Process each category reference.\n    foreach( $values as $value ){\n        \/\/ Call our other function to process each category.\n        $cat_list[] = my_get_cat_slug( $value, $id );\n    }\n\t\n    \/\/ Return a list of the located categories using the defined delimiter.\n    return implode($delimiter, $cat_list);\n}<\/code><\/pre><\/div>\n\n\n\n<p>The taxonomies section should be updated to something like below, making sure the delimiter provided matches that used in your file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"454\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/05\/import-multiple-categories-by-reference-1024x454.png\" alt=\"\" class=\"wp-image-3157786\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/05\/import-multiple-categories-by-reference-1024x454.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/05\/import-multiple-categories-by-reference-300x133.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/05\/import-multiple-categories-by-reference-768x341.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/05\/import-multiple-categories-by-reference.png 1062w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#find-file-elements-that-start-with-certain-text\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"find-file-elements-that-start-with-certain-text\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#find-file-elements-that-start-with-certain-text\" class=\"snippet-title\"><h2><strong>Find File Elements That Start with Certain Text<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use an XPath expression to return values for all elements in the file that start with 'image'. The values are returned separated by commas.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xpath\"><pre class=\"line-numbers\"><code class=\"language-xpath\">{.\/*[starts-with(local-name(), 'image')]}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#mapping-values\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"mapping-values\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#mapping-values\" class=\"snippet-title\"><h2><strong>Map File Values During Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use a custom function to map an amenity code in our file to its description. This allows us to match our imported values with those on our site. The code expects either a single amenity or a comma-separated string of values.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_map_amenities($amenities) {\n    \n    \/\/ Convert comma separated list to array.\n    $amenities = explode(\",\",$amenities);\n\t\n    \/\/ Define your mappings.\n    $map_values = array(\n        'BA'         =&gt; 'Balcony', \n        'SP'         =&gt; 'Shared Pool', \n        'SS'         =&gt; 'Shared Spa',\n        'file value' =&gt; 'returned value');\n\n    \/\/ Declare a new array for our mapped values.\t\n    $mapped_amenities = array();\n\n    \/\/ Process each amenity.\t\n    foreach($amenities as $amenity)\n    {\n        \n        \/\/ Check if we have a mapping for this amenity.\n        if(array_key_exists($amenity, $map_values)){\n\n            \/\/ If we do, use that value.\n            $mapped_amenities[] = $map_values[$amenity];\n        \n        } else {\n            \/\/ If we don't have a value mapping you \n            \/\/ can perform some other action.\n        }\n\t\t   \n    }\n\n    \/\/ Return the mapped values as a comma-separated string.\t\t   \n    return implode(\",\",$mapped_amenities);\n\n}<\/code><\/pre><\/div>\n\n\n\n<p>Here's how we call the function with our <code>amenities<\/code> element:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[soflyy_map_amenities({amenities[1]})]<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#enable-custom-fields-meta-box-on-post-admin\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"enable-custom-fields-meta-box-on-post-admin\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#enable-custom-fields-meta-box-on-post-admin\" class=\"snippet-title\"><h2><strong>Enable Custom Fields Section in Post Admin<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"acf\/settings\/remove_wp_meta_box (opens in a new tab)\" href=\"https:\/\/www.advancedcustomfields.com\/resources\/acf-settings\/\" target=\"_blank\">acf\/settings\/remove_wp_meta_box<\/a><\/code> filter to re-enable the Custom Fields section when editing posts. The code must be outside of the Function Editor - your theme's functions.php file is a good place.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-13-at-14.33.00-1024x811.png\" alt=\"\" class=\"wp-image-1620\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter('acf\/settings\/remove_wp_meta_box', '__return_false');<\/code><\/pre><\/div>\n\n\n\n<p>Here are the details from the ACF developer: <a href=\"https:\/\/www.advancedcustomfields.com\/blog\/acf-pro-5-6-0-ui-ux\/\">https:\/\/www.advancedcustomfields.com\/blog\/acf-pro-5-6-0-ui-ux\/<\/a><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#curl-error-60\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"curl-error-60\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#curl-error-60\" class=\"snippet-title\"><h2><strong>cURL Error 60<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/http_api_curl\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"http_api_curl (opens in a new tab)\">http_api_curl<\/a><\/code> to temporarily disable cURL's peer SSL verification. This allows us to download from HTTPS links that don't have a valid certificate chain. However, it's a potential security issue and only used as an emergency measure while the source site is fixed. The code must be placed outside the Function Editor - such as in your theme's functions.php file.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function curl_error_60_workaround( $handle, $r, $url ) {\n\n    \/\/ Disable peer verification to temporarily resolve error 60.\n    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);\n\n}\nadd_action( 'http_api_curl', 'curl_error_60_workaround', 10, 3 );<\/code><\/pre><\/div>\n\n\n\n<p>Here is a useful site for checking the validity of SSL certificates: <a href=\"https:\/\/www.sslshopper.com\/ssl-checker.html\">https:\/\/www.sslshopper.com\/ssl-checker.html<\/a><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#send-export-file-to-ftp-destination\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"send-export-file-to-ftp-destination\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#send-export-file-to-ftp-destination\" class=\"snippet-title\"><h2><strong>Send Export File to FTP Destination<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxe_after_export (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxe_after_export\" target=\"_blank\">pmxe_after_export<\/a><\/code> action to transfer our export file via FTP. We also make use of <code><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_attached_file\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"get_attached_file() (opens in a new tab)\">get_attached_file()<\/a><\/code> to retrieve the export file when WP All Export's Secure Mode is off.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">\/\/ Parts of this code were based on code from PHP Documentation Group, which is licensed under the Creative Commons Attribution 3.0 License.\n\/\/\n\/\/ You can read the Creative Commons Attribution 3.0 License here: https:\/\/creativecommons.org\/licenses\/by\/3.0\/\n\/\/\n\/\/ Also, hat tip to Daniel Stenberg for some additional code inspiration: https:\/\/curl.haxx.se\/libcurl\/php\/examples\/ftpupload.html\nfunction wpae_after_export( $export_id ) {\n\n    \/\/ Retrieve export object.\n    $export = new PMXE_Export_Record();\n    $export-&gt;getById($export_id);\n    \n    \/\/ Check if \"Secure Mode\" is enabled in All Export &gt; Settings.\n    $is_secure_export = PMXE_Plugin::getInstance()-&gt;getOption('secure');\n\n    \/\/ Retrieve file path when not using secure mode.\n    if ( !$is_secure_export) {\n        $filepath = get_attached_file($export-&gt;attch_id);\n\n    \/\/ Retrieve file path when using secure mode.                    \n    } else {\n        $filepath = wp_all_export_get_absolute_path($export-&gt;options['filepath']);\n    }\n\n    \/\/ Path to the export file.\n    $localfile = $filepath;\n\n    \/\/ File name of remote file (destination file name).\n    $remotefile = basename($filepath);\n    \n    \/\/ Remote FTP server details.\n    \/\/ The 'path' is relative to the FTP user's login directory.\n    $ftp = array(\n        'server' =&gt; 'enter-hostname-here',\n        'user' =&gt; 'enter-user-here',\n        'pass' =&gt; 'enter-password-here',\n        'path' =&gt; '\/enter\/path\/to\/folder\/here'\n    );\n\n    \/\/ Ensure username is formatted properly\n    $ftp['user'] = str_replace('@', '%40', $ftp['user']);\n    \n    \/\/ Ensure password is formatted properly\n    $ftp['pass'] = str_replace(array('#','?','\/','\\\\'), array('%23','%3F','%2F','%5C'), $ftp['pass']);\n    \n    \/\/ Remote FTP URL.\n    $remoteurl = \"ftp:\/\/{$ftp['user']}:{$ftp['pass']}@{$ftp['server']}{$ftp['path']}\/{$remotefile}\";\n\n    \/\/ Retrieve cURL object.\n    $ch = curl_init();\n\n    \/\/ Open export file.\n    $fp = fopen($localfile, \"rb\");\n    \n    \/\/ Proceed if the local file was opened.\n    if ($fp) {\n        \n        \/\/ Provide cURL the FTP URL.\n        curl_setopt($ch, CURLOPT_URL, $remoteurl);\n\n        \/\/ Prepare cURL for uploading files.\n        curl_setopt($ch, CURLOPT_UPLOAD, 1);\n\n        \/\/ Provide the export file to cURL.\n        curl_setopt($ch, CURLOPT_INFILE, $fp);\n\n        \/\/ Provide the file size to cURL.\n        curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));\n        \n        \/\/ Start the file upload.\n        curl_exec($ch);\n\n        \/\/ If there is an error, write error number &amp; message to PHP's error log.\n        if($errno = curl_errno($ch)) {\n            if (version_compare(phpversion(), '5.5.0', '&gt;=')) {\n                \n                \/\/ If PHP 5.5.0 or greater is used, use newer function for cURL error message.\n                $error_message = curl_strerror($errno);\n\n            } else {\n\n                \/\/ Otherwise, use legacy cURL error message function.\n                $error_message = curl_error($ch);\n            }\n\n            \/\/ Write error to PHP log.\n            error_log(\"cURL error ({$errno}): {$error_message}\");\n\n        }\n        \n        \/\/ Close the connection to remote server.\n        curl_close($ch);\n        \n    } else {\n\n        \/\/ If export file could not be found, write to error log.\n        error_log(\"Could not find export file\");\n\n    }\n}\nadd_action('pmxe_after_export', 'wpae_after_export', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#send-email-after-import-is-complete\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"send-email-after-import-is-complete\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#send-email-after-import-is-complete\" class=\"snippet-title\"><h2><strong>Send Email After Import is Complete<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxi_after_xml_import (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_after_xml_import\" target=\"_blank\">pmxi_after_xml_import<\/a><\/code> action to email the results of our import to <code>sendto@example.com<\/code>. We make use of the <a rel=\"noreferrer noopener\" aria-label=\"WPDB class (opens in a new tab)\" href=\"https:\/\/codex.wordpress.org\/Class_Reference\/wpdb\" target=\"_blank\">WPDB class<\/a> to retrieve the import stats and <code><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_mail\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_mail() (opens in a new tab)\">wp_mail()<\/a><\/code> to send the email.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpai_send_email($import_id) {\n    \/\/ Only send emails for import ID 1.\n    if($import_id != \"1\")\n        return;\n    \n    \/\/ Retrieve the last import run stats.\n    global $wpdb;\n    $table = $wpdb-&gt;prefix . \"pmxi_imports\";\n\n    if ( $soflyyrow = $wpdb-&gt;get_row( $wpdb-&gt;prepare( \"SELECT * FROM `\" . $table . \"` WHERE `id` = '%d'\", $import_id ) ) ) {\n        \n        $count = $soflyyrow-&gt;count;\n        $imported = $soflyyrow-&gt;imported;\n        $created = $soflyyrow-&gt;created;\n        $updated = $soflyyrow-&gt;updated;\n        $skipped = $soflyyrow-&gt;skipped;\n        $deleted = $soflyyrow-&gt;deleted;\n\n    }\n    \n    \/\/ Destination email address.\n    $to = 'sendto@example.com';\n\n    \/\/ Email subject.\n    $subject = 'Import ID: '.$import_id.' complete';\n\n    \/\/ Email message.\n    $body = 'Import ID: '.$import_id.' has completed at '. date(\"Y-m-d H:m:s\"). \"\\r\\n\" . 'File Records:' .$count.\"\\r\\n\".'Records Imported:'.$imported.\"\\r\\n\".'Records Created:'.$created;\n    $body .= \"\\r\\n\" . 'Records Updated:'. $updated . \"\\r\\n\" . 'Records Skipped:' . $skipped . \"\\r\\n\" . 'Records Deleted:' . $deleted;\n\n    \/\/ Send the email as HTML.\n    $headers = array('Content-Type: text\/html; charset=UTF-8');\n \n    \/\/ Send via WordPress email.\n    wp_mail( $to, $subject, $body, $headers );\n}\nadd_action('pmxi_after_xml_import', 'wpai_send_email', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#append-acf-repeater-data\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"append-acf-repeater-data\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#append-acf-repeater-data\" class=\"snippet-title\"><h2><strong>Append ACF Repeater Data<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_saved_post (opens in a new tab)\">pmxi_saved_post<\/a><\/code> action to append a row to the <code>repeater_text<\/code> field of our <code>basic_repeater<\/code>. This workaround is required since our source file has repeater data spread across multiple rows. We use the <code><a rel=\"noreferrer noopener\" aria-label=\"add_row() (opens in a new tab)\" href=\"https:\/\/www.advancedcustomfields.com\/resources\/add_row\/\" target=\"_blank\">add_row()<\/a><\/code> function to save our new repeater row.<\/p>\n\n\n\n<p>We use an <a href=\"\/documentation\/recurring\/manual-record-matching\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Existing Items import (opens in a new tab)\">Existing Items import<\/a> since our ACF posts already exist. Then we store our value to append in the <code>my_repeater_data<\/code> custom field:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Shot-07172017-12_33.png\" alt=\"\" class=\"wp-image-1278\"\/><\/figure>\n\n\n\n<p>We tell WP All Import to update the <code>my_repeater_data<\/code> field:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Shot-07172017-12_36.png\" alt=\"\" class=\"wp-image-1277\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_add_data( $id, $xml, $update ) {\n\n    \/\/ Parent field name.\n    $selector = 'basic_repeater';\n\n    \/\/ The field to be appended.\n    $subfield1 = 'repeater_text'; \n    \n    \/\/ Only continue if my_repeater_data contains a value.\n    if ( $value = get_post_meta( $id, 'my_repeater_data', true ) ) {\n        \n        \/\/ Format data for repeater.\n        $row = array( $subfield1 =&gt; $value );\n\n        \/\/ Add new repeater row.\n        add_row( $selector, $row, $id );\n\n    }\n    delete_post_meta( $id, 'my_repeater_data' );\n}\nadd_action( 'pmxi_saved_post', 'soflyy_add_data', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#custom-items-loop-for-woocommerce-orders-exports\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"custom-items-loop-for-woocommerce-orders-exports\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#custom-items-loop-for-woocommerce-orders-exports\" class=\"snippet-title\"><h2><strong>Custom Items Loop for WooCommerce Orders Exports<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use custom code to modify the format of exported Order items. In this case, we need one product per <code>item<\/code> element instead of all products in <code>items<\/code> directly. Here's our Custom XML template:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;items&gt;\n  &lt;ProductID&gt;{Product ID}&lt;\/ProductID&gt;\n  &lt;SKU&gt;{SKU}&lt;\/SKU&gt;\n  &lt;Quantity&gt;{Quantity}&lt;\/Quantity&gt;\n  &lt;ItemCost&gt;{Item Cost}&lt;\/ItemCost&gt;\n&lt;\/items&gt;<\/code><\/pre><\/div>\n\n\n\n<p>The output would look like this:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;items&gt;\n  &lt;ProductID&gt;197&lt;\/ProductID&gt;\n  &lt;ProductID&gt;195&lt;\/ProductID&gt;\n  &lt;SKU&gt;KEYB3&lt;\/SKU&gt;\n  &lt;SKU&gt;KEYB2&lt;\/SKU&gt;\n  &lt;Quantity&gt;1&lt;\/Quantity&gt;\n  &lt;Quantity&gt;5&lt;\/Quantity&gt;\n  &lt;ItemCost&gt;30.00&lt;\/ItemCost&gt;\n  &lt;ItemCost&gt;30.00&lt;\/ItemCost&gt;\n&lt;\/items&gt;<\/code><\/pre><\/div>\n\n\n\n<p>To achieve the desired format, we need to reconfigure our export template to instead call our custom function:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">&lt;items> \n   [my_output_items({SKU},{Product ID},{Quantity},{Item Cost})] \n&lt;\/items><\/code><\/pre><\/div>\n\n\n\n<p>And disable the automatic use of CDATA tags:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/cdatatags.png\" alt=\"\" class=\"wp-image-1280\"\/><\/figure>\n\n\n\n<p>Then our exported format becomes:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;items&gt;\n  &lt;item&gt;\n    &lt;ProductID&gt;197&lt;\/ProductID&gt;\n    &lt;SKU&gt;KEYB3&lt;\/SKU&gt;\n    &lt;Quantity&gt;1&lt;\/Quantity&gt;\n    &lt;ItemCost&gt;30.00&lt;\/ItemCost&gt;\n  &lt;\/item&gt;\n  &lt;item&gt;\n    &lt;ProductID&gt;195&lt;\/ProductID&gt;\n    &lt;SKU&gt;KEYB2&lt;\/SKU&gt;\n    &lt;Quantity&gt;5&lt;\/Quantity&gt;\n    &lt;ItemCost&gt;30.00&lt;\/ItemCost&gt;\n  &lt;\/item&gt;\n&lt;\/items&gt;<\/code><\/pre><\/div>\n\n\n\n<p>We save this code to WP All Export's Function Editor:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_output_items( $skus = '', $ids = '', $qty = '', $cost = '' ) {\n\t\n    \/\/ Declare our variable to store the new XML.\n    $xml = '';\n\t\n    \/\/ Ensure $skus isn't empty and that it's an array.\n    if ( !empty( $skus ) &amp;&amp; is_array( $skus ) ) {\n\n        \/\/ Process each SKU in the array.\n        foreach ( $skus as $key =&gt; $value ) {\n\n            \/\/ Add the opening item tag.\n            $xml .= \"**LT**item**GT**\";\n\n            \/\/ Add the Product ID tags and value.\n            $xml .= \"**LT**ProductID**GT**\" . ( empty( $ids[ $key ] ) ? '' : $ids[ $key ] ) . \"**LT**\/ProductID**GT**\";\n\n            \/\/ Add the SKU tags and value.\n            $xml .= \"**LT**SKU**GT**\" . ( empty( $value ) ? '' : $value ) . \"**LT**\/SKU**GT**\";\n\n            \/\/ Add the Quantity tags and value.\n            $xml .= \"**LT**Quantity**GT**\" . ( empty( $qty[ $key ] ) ? '' : $qty[ $key ] ) . \"**LT**\/Quantity**GT**\";\n\n            \/\/ Add the ItemCost tags and value.\n            $xml .= \"**LT**ItemCost**GT**\" . ( empty( $cost[ $key ] ) ? '' : $cost[ $key ] ) . \"**LT**\/ItemCost**GT**\";\n\n            \/\/ Add the closing item tag.\n            $xml .= \"**LT**\/item**GT**\";\n        }\n\n    \/\/ If $skus isn't an array handle it here.\n    } else {\n\n        \/\/ Add the opening item tag.\n        $xml .= \"**LT**item**GT**\";\n\n        \/\/ Add the ProductID tags and value.\t\t\n        $xml .= \"**LT**ProductID**GT**\" . ( empty( $ids ) ? '' : $ids ) . \"**LT**\/ProductID**GT**\";\n\n        \/\/ Add the SKU tags and value.\n        $xml .= \"**LT**SKU**GT**\" . ( empty( $skus ) ? '' : $skus ) . \"**LT**\/SKU**GT**\";\n\n        \/\/ Add the Quantity tags and value.\n        $xml .= \"**LT**Quantity**GT**\" . ( empty( $qty ) ? '' : $qty ) . \"**LT**\/Quantity**GT**\";\n\n        \/\/ Add the ItemCost tags and value.\n        $xml .= \"**LT**ItemCost**GT**\" . ( empty( $cost ) ? '' : $cost ) . \"**LT**\/ItemCost**GT**\";\n\n        \/\/ Add the closing item tag.\n        $xml .= \"**LT**\/item**GT**\";\n    }\n\n    return $xml;\n\n}<\/code><\/pre><\/div>\n\n\n\n<p>You can learn more about PHP functions in custom XML exports via the \"Help\" button:&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/custom_xml_php_functions.png\" alt=\"\" class=\"wp-image-1281\"\/><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#check-the-number-of-posts-imported\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"check-the-number-of-posts-imported\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#check-the-number-of-posts-imported\" class=\"snippet-title\"><h2><strong>Count Number of Created Posts<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_after_xml_import\ufeff\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_after_xml_import (opens in a new tab)\">pmxi_after_xml_import<\/a><\/code> action to count the number of posts created during the import.  Using that number we can selectively perform other tasks.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function count_created_posts( $import_id ){\n\n    \/\/ Only count created posts for import ID 1.\n    if( $import_id == 1 ){\n\n        \/\/ Query the database directly.\n        global $wpdb;\n        $import = $wpdb-&gt;get_row( $wpdb-&gt;prepare( \"SELECT * FROM `\" . $wpdb-&gt;prefix . \"pmxi_imports` WHERE ID = %d;\", $import_id ) );\n\n        \/\/ Define the number of created posts.\n        $created = $import-&gt;created;\n\n        if ( $created &gt; 0 ) {\n\n            \/\/ Do something if posts were created during import.\n\n        }\n    }\n}\nadd_action('pmxi_after_xml_import', 'count_created_posts', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-continue-import-if-import-file-contains-records\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-continue-import-if-import-file-contains-records\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-continue-import-if-import-file-contains-records\" class=\"snippet-title\"><h2><strong>Cancel Import If File Empty<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxi_before_xml_import (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_before_xml_import\" target=\"_blank\">pmxi_before_xml_import<\/a><\/code> action to cancel the import if less than 100 records are in the file. This is especially important if using the 'Delete posts that are no longer present in your file' option (Step 4 or Manage Imports &gt; Import Settings). When using that option, this keeps the previously imported records intact if the feed fails to return data.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function cancel_empty_import( $importID ) {\n\n    \/\/ Retrieve import object. \n    $import = new PMXI_Import_Record(); \n    $import-&gt;getById($importID);\n\n    \/\/ Ensure object is valid and check if less than 100\n    \/\/ records are in the file.\t \n    if ( !$import-&gt;isEmpty() &amp;&amp; $import-&gt;count &lt; 100 ) { \n        \n        \/\/ Load history file object.\n        $history_file = new PMXI_File_Record(); \n        $history_file-&gt;getBy( 'import_id', $importID ); \n\n        \/\/ Ensure object is valid.\n        if ( !$history_file-&gt;isEmpty() ) {  \n\n            \/\/ Retrieve import file path.\n            $file_to_import = wp_all_import_get_absolute_path( $history_file-&gt;path );\n\n  \n            \/\/ If file is empty or has less than 100 records,\n            \/\/ cancel import.\n            if ( file_exists( $file_to_import ) and filesize( $file_to_import ) === 0 or $import-&gt;count &lt; 100 ) { \n\n\n                \/\/ Reset import stats to 0.\n                $import-&gt;set( array( \n                    'queue_chunk_number' =&gt; 0,\n                    'processing' =&gt; 0, \n                    'imported' =&gt; 0, \n                    'created' =&gt; 0, \n                    'updated' =&gt; 0, \n                    'skipped' =&gt; 0, \n                    'deleted' =&gt; 0, \n                    'triggered' =&gt; 0, \n                    'executing' =&gt; 0\t \n                ))-&gt;update();\n\n            \/\/ Display the reason the import was cancelled.  \n            echo 'Import skipped because of empty file \/ &lt; 100 records';  \n\n            \/\/ Stop the import. \n            die(); \n            }\t \n        }\t \n    } \n}\nadd_action( 'pmxi_before_xml_import', 'cancel_empty_import', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#delete-import-file-after-import\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"delete-import-file-after-import\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#delete-import-file-after-import\" class=\"snippet-title\"><h2><strong>Delete Source File After Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_after_xml_import\">pmxi_after_xml_import<\/a><\/code> action to delete the source file once imported. This can prevent the same import file from being imported twice. It's also helpful if you're pushing the import file to your server via FTP and need to know when it has been processed.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function delete_import_file( $import_id ) {\n\n    \/\/ Retrieve import object.\n    $import = new PMXI_Import_Record();\n    $import-&gt;getById( $import_id );\n\n    \/\/ Confirm import object is valid.\n    if ( ! $import-&gt;isEmpty() ) {\n        \n        \/\/ Retrieve file information.\n        $history_file = new PMXI_File_Record(); \n        $history_file-&gt;getBy( 'import_id', $import_id );\n\n        \/\/ Confirm file isn't empty. \n        if ( !$history_file-&gt;isEmpty() ) {\n\n            \/\/ Retrieve file path.  \n            $import_file = wp_all_import_get_absolute_path( $history_file-&gt;path );\n\n            \/\/ Mark file for deletion.\n            @unlink( $import_file );\n\n\t\t}\n\t}\n}\nadd_action( 'pmxi_after_xml_import', 'delete_import_file', 10, 1 );<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#manually-set-import-file-type\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"manually-set-import-file-type\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#manually-set-import-file-type\" class=\"snippet-title\"><h2><strong>Manually Set Import Feed Type<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"wp_all_import_feed_type (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_feed_type\" target=\"_blank\">wp_all_import_feed_type<\/a><\/code> filter to specify we are importing an XML feed. This may be necessary if your feed URL doesn't end with the type - <code>csv<\/code>, <code>xml<\/code>, <code>json<\/code>, etc.  This code must be called outside of WP All Import's Function Editor in a place such as your theme's functions.php file.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function set_feed_type( $type, $url ){\n\n    \/\/ Specify Feed URL.\n    if ($url == 'https:\/\/www.example.com\/feedurl'){\n\n        \/\/ Set feed type.\n        $type = 'xml';\n\n    }\n\n    \/\/ If URL doesn't match our feed return the default type.\n    return $type;\n\n}\nadd_filter( 'wp_all_import_feed_type', 'set_feed_type', 10, 2 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#combine-html-elements-in-xml-without-cdata-tags\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"combine-html-elements-in-xml-without-cdata-tags\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#combine-html-elements-in-xml-without-cdata-tags\" class=\"snippet-title\"><h2><strong>Combine HTML Elements In XML Without CDATA Tags<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use custom code to copy the HTML in our XML file to its own element. This is required to import that HTML since it wasn't encoded or wrapped in CDATA tags. Otherwise, the individual HTML tags will be processed as XML tags by WP All Import. It's best to have a properly formed XML file, but we can fix it with code.<\/p>\n\n\n\n<p>Our HTML is stored in the <code>content<\/code> element in our file. Our code loads that element and ensures it's not empty. Then keywords in our HTML are replace with their HTML tag equivalents. Finally, we write the HTML to its own element, <code>content_html<\/code>, so we can use it in our import.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function parse_content($node) {\n\n    \/\/ Our element containing the HTML to process.\n    $result = $node-&gt;xpath('content');\n\n    \/\/ Ensure a value was returned.\n    if (!empty($result[0])) {\n\n        \/\/ Replace keywords with HTML equivalents.\n        $find_xml = array('section_title','section_content','section', 'texteparagraphe','titreparagraphe');\n        $replace_html = array('h1','p','div','p','h2');\n        $html = str_replace($find_xml, $replace_html, $result[0]-&gt;asXML());\n\n        \/\/ Save the HTML to its own 'content_html' element.\n        $node-&gt;addChild('content_html', $html);\n    }\n\n    return $node;\n\n}\nadd_filter('wpallimport_xml_row', 'parse_content', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#add-elements-to-xml-on-the-fly\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"add-elements-to-xml-on-the-fly\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#add-elements-to-xml-on-the-fly\" class=\"snippet-title\"><h2><strong>Modify Record Before It's Imported<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wpallimport_xml_row\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wpallimport_xml_row (opens in a new tab)\">wpallimport_xml_row<\/a><\/code> filter to check the <code>Blue<\/code> element for a value.  If it has one, we create an element named <code>Color<\/code> and set it to <code>Blue<\/code>.  We do the same for the <code>Red<\/code> element.  This works for all file types, not just XML.<\/p>\n\n\n\n<p>Here's our starting CSV file:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>Name<\/td><td>Size<\/td><td>Blue<\/td><td>Red<\/td><\/tr><tr><td>Large Blue Hat<\/td><td>Large<\/td><td>Yes<\/td><td><\/td><\/tr><tr><td>Small Red Hat<\/td><td>Small<\/td><td><\/td><td>Yes<\/td><\/tr><tr><td>Medium Red and Blue Hat<\/td><td>Medium<\/td><td>Yes<\/td><td>Yes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Here's the CSV equivalent of how WP All Import sees it after our code runs:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>Name<\/td><td>Size<\/td><td>Blue<\/td><td>Red<\/td><td>Color<\/td><td>Color<\/td><\/tr><tr><td>Large Blue Hat<\/td><td>Large<\/td><td>Yes<\/td><td><\/td><td>Blue<\/td><td><\/td><\/tr><tr><td>Small Red Hat<\/td><td>Small<\/td><td><\/td><td>Yes<\/td><td><\/td><td>Red<\/td><\/tr><tr><td>Medium Red and Blue Hat<\/td><td>Medium<\/td><td>Yes<\/td><td>Yes<\/td><td>Blue<\/td><td>Red<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Doing this allows the <code>{color}<\/code> XPath to return all of the <code>Color<\/code> values separated by commas.  Here's what's returned for each row above:<\/p>\n\n\n\n<figure class=\"wp-block-table aligncenter is-style-stripes\"><table><tbody><tr><td>Blue,<\/td><\/tr><tr><td>,Red<\/td><\/tr><tr><td>Blue,Red<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function add_property_type( $node ) {\n    \/\/ Element to be located\n    $blue = $node-&gt;xpath( 'blue[1]' );\n    \n    \/\/ Check if Blue element has value\n    if ( ! empty( $blue ) ) {\n        if ( ! empty( $blue[0]-&gt;__toString() ) ) {\n            \/\/ add Color node with value 'Blue'\n            $node-&gt;addChild( 'color', 'Blue' );\n        }\n    }\n    \n    \/\/ Element to be located\n    $red = $node-&gt;xpath( 'red[1]' );\n    \n    \/\/ Check if Red element has value\n    if ( ! empty( $red ) ) {\n        if ( ! empty( $red[0]-&gt;__toString() ) ) {\n            \/\/ add Color node with value 'Red'\n            $node-&gt;addChild( 'color', 'Red' );\n        }\n    }\n    return $node;\n}\nadd_filter( 'wpallimport_xml_row', 'add_property_type', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#append-data-to-a-custom-field-instead-of-replacing-it\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"append-data-to-a-custom-field-instead-of-replacing-it\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#append-data-to-a-custom-field-instead-of-replacing-it\" class=\"snippet-title\"><h2><strong>Append Data To A Custom Field Instead Of Overwriting<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we are using the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">pmxi_saved_post<\/a><\/code> action to append an additional value to the <code>your_meta_key<\/code> field. This allows importing values from multiple rows in our file to a single post's custom field. We must import the new value to the <code>_temp<\/code> custom field first:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-27-at-7.33.48-PM-1024x345.png\" alt=\"\" class=\"wp-image-1388\"\/><\/figure>\n\n\n\n<p>The field you append must not be updated by WP All Import or the original value will be lost (Step 4 or Manage Imports &gt; Import Settings): <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-27-at-19.08.33-1024x946.png\" alt=\"\" class=\"wp-image-1387\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function custom_field_append($id) {\n    \/\/ Get the current value of your meta key.\n    $value = get_post_meta($id, 'your_meta_key', true);\n\n    \/\/ Get the temp value we imported.\n    $temp = get_post_meta($id, '_temp', true);\n\n    \/\/ Append the temp value to the original value and\n    \/\/ save it to your meta key\n    update_post_meta($id, 'your_meta_key', $value . $temp);\n\n    \/\/ Delete the temp field.\n    delete_post_meta($id, '_temp');\n\n}\nadd_action('pmxi_saved_post', 'custom_field_append', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-custom-field-if-another-field-has-a-certain-value\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-custom-field-if-another-field-has-a-certain-value\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-custom-field-if-another-field-has-a-certain-value\" class=\"snippet-title\"><h2><strong>Update Second Custom Field If First Field Has Specified Value<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_saved_post (opens in a new tab)\">pmxi_saved_post<\/a><\/code> action, <code><a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\">get_post_meta()<\/a><\/code>, and <code><a rel=\"noreferrer noopener\" aria-label=\"update_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/update_post_meta\/\" target=\"_blank\">update_post_meta()<\/a><\/code> to only update <code>_my_custom_field<\/code> if <code>_my_update_check<\/code> is set to 'yes'.  The new value is stored in <code>_my_new_value<\/code> during import and copied to <code>_my_custom_field<\/code> as needed.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function conditional_update($id) {\n    \n    \/\/ Retrieve field to check.\n    $check = get_post_meta($id, '_my_update_check', true);\n\n    \/\/ Check field's value and update _my_custom_field if 'yes'.\n    if ($check === 'yes') {\n\n        \/\/ Retrieve the new value.\n        $new_value = get_post_meta($id, '_my_new_value', true);\n\n        \/\/ Save the new value to the target field.\n        update_post_meta($id, '_my_custom_field', $new_value);\n    }\n}\nadd_action('pmxi_saved_post', 'conditional_update', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#use-parent-prices-for-variations\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"use-parent-prices-for-variations\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#use-parent-prices-for-variations\" class=\"snippet-title\"><h2><strong>Use Parent Prices For Variations<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <a rel=\"noreferrer noopener\" aria-label=\"pmxi_saved_post (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\">pmxi_saved_post<\/a> action to assign the <code>_parent_price<\/code> value to each variation. This is necessary because our file only lists parent prices. The get_post_meta() function is used to retrieve _parent_price.  Then wc_get_product() is used to get the product's object <br><\/p>\n\n\n\n<p>If you're trying to use a <a rel=\"noreferrer noopener\" aria-label=\"price update import (opens in a new tab)\" href=\"\/documentation\/woocommerce\/updating-prices\/\" target=\"_blank\">price update import<\/a> and only have a file with prices for the parent products, you'll need some custom code to apply those prices to the variations.  <\/p>\n\n\n\n<p>Be sure to set the price to a custom field named '_parent_price'.  Then the code below should be helpful:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_set_price($post_id) {\n\n    \/\/ Get the parent price.\n    $parent_price = get_post_meta($post_id, \"_parent_price\", true);\n\n    \/\/ Get the parent product object.\n    $parent = wc_get_product($post_id);\n\n    \/\/ Check if it's a variable product.\n    if( $parent &amp;&amp; 'variable' == $parent-&gt;get_type() ){\n\n        \/\/ Get product's variations.\n        $variations = $parent-&gt;get_children();\n        \/\/ Loop through the variations and set the price\n        foreach ($variations as $variation) {\n            $single_variation = wc_get_product($variation);\n\t    $variation_id = $single_variation-&gt;get_variation_id();\n\t    update_post_meta($variation_id, \"_price\", $parent_price);\n\t    update_post_meta($variation_id, \"_regular_price\", $parent_price);\n\t}\n    delete_post_meta($post_id, \"_parent_price\");\n\n    }\n}\nadd_action( 'pmxi_saved_post', 'my_set_price', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#access-data-above-element-chosen-on-step-2\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"access-data-above-element-chosen-on-step-2\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#access-data-above-element-chosen-on-step-2\" class=\"snippet-title\"><h2><strong>Access Data Outside of Element Chosen on Step 2<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\" (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_before_xml_import\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_before_xml_import<\/a><\/code> action to add <code>Status<\/code> as a child to each <code>Procurement<\/code> element, allowing it to be selected on Step 3. Note that this workaround only works for XML imports.<\/p>\n\n\n\n<p>Here is the original XML structure:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;Apartment&gt;\n    &lt;Key&gt;32434&lt;\/Key&gt;\n\n    &lt;!-- Status element is outside of Procurement elements --&gt;\n    &lt;Status&gt;On&lt;\/Status&gt;\n    &lt;Procurements&gt;\n        &lt;Procurement&gt;\n            &lt;Id&gt;16683&lt;\/Id&gt;\n            &lt;Description&gt;\n                Description\n            &lt;\/Description&gt;\n        &lt;\/Procurement&gt;\n        &lt;Procurement&gt;\n            &lt;Id&gt;16684&lt;\/Id&gt;\n            &lt;Description&gt;\n                Description 2\n            &lt;\/Description&gt;\n        &lt;\/Procurement&gt;\n    &lt;\/Procurements&gt;\n&lt;\/Apartment&gt;<\/code><\/pre><\/div>\n\n\n\n<p>On Step 3 we can't select <code>Status<\/code> since it's not a child of the element chosen on Step 2, <code>Procurement<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-27-at-4.37.17-PM-1024x489.png\" alt=\"\" class=\"wp-image-1385\"\/><\/figure>\n\n\n\n<p>After the code runs, the file looks like this:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;Apartment&gt;\n    &lt;Key&gt;32434&lt;\/Key&gt;\n    &lt;Status&gt;On&lt;\/Status&gt;\n    &lt;Procurements&gt;\n        &lt;Procurement&gt;\n            &lt;Id&gt;16683&lt;\/Id&gt;\n            &lt;Description&gt;\n                Description\n            &lt;\/Description&gt;\n\n            &lt;!-- Status has been copied to each Procurement element --&gt;\n            &lt;Status&gt;On&lt;\/Status&gt;\n        &lt;\/Procurement&gt;\n        &lt;Procurement&gt;\n            &lt;Id&gt;16684&lt;\/Id&gt;\n            &lt;Description&gt;\n                Description 2\n            &lt;\/Description&gt;\n\n            &lt;!-- Status has been copied to each Procurement element --&gt;\n            &lt;Status&gt;On&lt;\/Status&gt;\n        &lt;\/Procurement&gt;\n    &lt;\/Procurements&gt;\n&lt;\/Apartment&gt;<\/code><\/pre><\/div>\n\n\n\n<p>Making <code>Status<\/code> available on Step 3:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-27-at-4.40.04-PM-1024x570.png\" alt=\"\" class=\"wp-image-1386\"\/><\/figure>\n\n\n\n<p><strong>Note:<\/strong> <code>Status<\/code> won't show up in the list until the import first runs.  But, it can be typed in manually and used: <code>{Status[1]}<\/code><\/p>\n\n\n\n<div style=\"height:33px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpai_pmxi_before_xml_import( $importID ) {\n\n    \/\/ Retrieve import object.\n    $import = new PMXI_Import_Record();\n    $import-&gt;getById( $importID );\n\n    \/\/ Ensure import object is valid.\n    if ( ! $import-&gt;isEmpty() ) {\n\n        \/\/ Retrieve history file object.\n        $history_file = new PMXI_File_Record();\n        $history_file-&gt;getBy( 'import_id', $importID );\n\n        \/\/ Ensure history file object is valid.\n        if ( ! $history_file-&gt;isEmpty() ) {\n\n            \/\/ Retrieve import file path.\n            $file_to_import = wp_all_import_get_absolute_path( $history_file-&gt;path );\n\n            \/\/ Load import file as SimpleXml.\n            $file = simplexml_load_file( $file_to_import );\n\n            \/\/ Check if Status is a child of Procurement.\n            $query = $file-&gt;xpath( \"\/\/Apartment\/Procurements[1]\/Procurement[1]\/Status[1]\" );\n            if ( ! empty( $query ) ) {\n\n                \/\/ If it is, do nothing.\n                return;\n\n            }\n\n            \/\/ Get Status value.\n            $iquery = $file-&gt;xpath( \"\/\/Apartment\/Status[1]\" );\n\n            \/\/ Ensure value isn't empty.\n            if ( ! empty( $iquery ) ) {\n\n                \/\/ Value of status as string.\n                $status = $iquery[0]-&gt;__toString();\n\n                \/\/ Target path.\n                $new_query = $file-&gt;xpath( \".\/Procurements\/Procurement\" );\n\n                \/\/ Ensure path is valid.\n                if ( ! empty( $new_query ) ) {\n\n                    \/\/ Process each Procurement element.\n                    foreach ( $new_query as $record ) {\n\n                        \/\/ Ensure this element doesn't have Status.\n                        if ( ! isset( $record-&gt;Status ) ) {\n\n                        \/\/ Add {Status[1]} as child node.\n                        $record-&gt;addChild( 'Status', $status );\n\n                        }\n                    }\n\n                    \/\/ Save updated file.\n                    $updated_file = $file-&gt;asXML( $file_to_import );\n\n                }\n            }\n        }\n    }\n}\nadd_action( 'pmxi_before_xml_import', 'wpai_pmxi_before_xml_import', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#convert-features-with-0-and-1-values-to-comma-delimited-list\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"convert-features-with-0-and-1-values-to-comma-delimited-list\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#convert-features-with-0-and-1-values-to-comma-delimited-list\" class=\"snippet-title\"><h2><strong>Map Values to Element Name Based on Value<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wpallimport_xml_row\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wpallimport_xml_row (opens in a new tab)\">wpallimport_xml_row<\/a><\/code> filter to map our boolean fields to a new element with string values. This is needed since our file contains one element for each feature with a value of either 0 or 1. All fields with a value of 1 must have their name copied to a new element for import.<\/p>\n\n\n\n<p>Here's an example of our file:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Name<\/td><td>pool<\/td><td>patio<\/td><td>basement<\/td><td>deck<\/td><td>airconditioning<\/td><\/tr><tr><td>Villa<\/td><td>1<\/td><td>1<\/td><td>0<\/td><td>0<\/td><td>0<\/td><\/tr><tr><td>House<\/td><td>0<\/td><td>1<\/td><td>1<\/td><td>1<\/td><td>1<\/td><\/tr><tr><td>Apartment<\/td><td>1<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We can handle this mapping with some custom code. The end result represented as CSV is below:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Name<\/td><td>pool<\/td><td>patio<\/td><td>basement<\/td><td>deck<\/td><td>airconditioning<\/td><td>mycustomfeatures<\/td><\/tr><tr><td>Villa<\/td><td>1<\/td><td>1<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>Pool, Patio<\/td><\/tr><tr><td>House<\/td><td>0<\/td><td>1<\/td><td>1<\/td><td>0<\/td><td>1<\/td><td>Patio, Basement, Air Conditioning<\/td><\/tr><tr><td>Apartment<\/td><td>1<\/td><td>0<\/td><td>0<\/td><td>0<\/td><td>1<\/td><td>Pool, Air Conditioning<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>That allows using the <code>{mycustomfeatures[1]}<\/code> element in our import configuration as needed (Step 3 or Manage Imports &gt; Edit Import).<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function add_feature_node( $node ) {\n\n    \/\/ Our mappings from element name to string.\n    $fields = array(\n        \"pool\"              =&gt; \"Pool\",\n        \"patio\"             =&gt; \"Patio\",\n        \"basement\"          =&gt; \"Basement\",\n        \"deck\"              =&gt; \"Deck\",\n        \"airconditioning\"   =&gt; \"Air Conditioning\"\n    );\n\n    \/\/ Process each element.\n    foreach ( $fields as $key =&gt; $field ) {\n\n        \/\/ Retrieve the field's value.\n        $result = $node-&gt;xpath( $key . '[1]' );\n\n        \/\/ Check if element doesn't exist or contains an empty value\n        if ( !isset( $result[0] ) || empty( $result[0]-&gt;__toString() ) ) {\n\n            \/\/ If so, don't list that feature.\n            unset( $fields[ $key ] );\n\n        }\n\n    }\n\n    \/\/ Add the comma separated features to our new element.\n    $node-&gt;addChild( 'mycustomfeatures', implode( \",\", $fields ) );\n\n    return $node;\n}\nadd_filter( 'wpallimport_xml_row', 'add_feature_node', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#match-by-sku-when-the-skus-on-your-site-contain-extra-characters\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"match-by-sku-when-the-skus-on-your-site-contain-extra-characters\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#match-by-sku-when-the-skus-on-your-site-contain-extra-characters\" class=\"snippet-title\"><h2><strong>Match By SKU When The SKUs On Your Site Contain Extra Characters<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"WPDB class' (opens in a new tab)\" href=\"https:\/\/codex.wordpress.org\/Class_Reference\/wpdb\" target=\"_blank\">WPDB class'<\/a><\/code> <code><a rel=\"noreferrer noopener\" aria-label=\"get_var() (opens in a new tab)\" href=\"https:\/\/codex.wordpress.org\/Class_Reference\/wpdb#SELECT_a_Variable\" target=\"_blank\">get_var()<\/a><\/code> method to retrieve the products matching our SKUs. Using <code><a href=\"https:\/\/mariadb.com\/kb\/en\/replace\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"REPLACE (opens in a new tab)\">REPLACE<\/a><\/code> we ignore an unwanted slash that's used in each SKU on the site, but not in our file: <code>my\/sku<\/code> vs <code>mysku<\/code><\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function get_product_by_sku( $sku ) {\n\n    \/\/ Access WPDB object.\n    global $wpdb;\n\n    \/\/ Match by our files SKU and ignore slashes in the database.\n    $product_id = $wpdb-&gt;get_var( $wpdb-&gt;prepare( \"SELECT post_id FROM $wpdb-&gt;postmeta WHERE meta_key='_sku' AND REPLACE(meta_value, '\/', '')='%s' LIMIT 1\", $sku ) );\n\n    \/\/ If a match was found return its ID.\n    if ( $product_id ) return $product_id;\n\n    return null;\n}<\/code><\/pre><\/div>\n\n\n\n<p>We call our function on Step 4 of an <a rel=\"noreferrer noopener\" aria-label=\"Existing Items (opens in a new tab)\" href=\"\/documentation\/bulk-edit\/update-existing-posts\/\" target=\"_blank\">Existing Items<\/a> import. Our files SKU element is passed as the only parameter:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-06-22-at-23.36.15.png\" alt=\"\" class=\"wp-image-1299\"\/><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-acf-post2post-plugin-bidirectional-fields\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-acf-post2post-plugin-bidirectional-fields\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-acf-post2post-plugin-bidirectional-fields\" class=\"snippet-title\"><h2><strong>Import ACF Bidirectional Fields<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\"pmxi_acf_custom_field (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_acf_custom_field\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_acf_custom_field<\/a><\/code> filter to allow importing ACF bidirectional fields. This can also be used with the ACF Post2Post Plugin.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function import_set_bidiretional_fields( $value, $post_id, $name ) {\n\n\t\/\/ Get ACF field object by name.\n\t$field = get_field_object($name, $post_id);\n\n\t\/\/ Take no action if field is empty.\n\tif( empty($field) ) {\n\t\treturn $value;\n\t}\n\n\t\/\/ Apply update_value filter to trigger acf-post2post plugin.\n\tif ( $field['type'] == 'relationship' ) {\n\t\t$value = apply_filters( \"acf\/update_value\/type={$field['type']}\", $value, $post_id, $field );\n\t}\n\n\t\/\/ Return the original field value.\n\treturn $value;\n}\nadd_filter( 'pmxi_acf_custom_field', 'import_set_bidiretional_fields', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-wp-user-avatar-image-when-importing-users-or-customers\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-wp-user-avatar-image-when-importing-users-or-customers\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-wp-user-avatar-image-when-importing-users-or-customers\" class=\"snippet-title\"><h2><strong>Import Images to WP User Avatar Plugin<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">pmxi_saved_post<\/a><\/code> action to save images to the <a rel=\"noreferrer noopener\" aria-label=\"WP User Avatar (opens in a new tab)\" href=\"https:\/\/wordpress.org\/plugins\/wp-user-avatar\/\" target=\"_blank\">WP User Avatar<\/a> plugin. Using <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_user_meta\/\" target=\"_blank\"><code>get_user_meta()<\/code><\/a> we retrieve the avatar URL from the custom field. The <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/media_sideload_image\/\" target=\"_blank\"><code>media_sideload_image()<\/code><\/a> function saves the image to WordPress. We make use of <a rel=\"noreferrer noopener\" aria-label=\"add_action() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/add_action\/\" target=\"_blank\"><code>add_action()<\/code><\/a> and <a rel=\"noreferrer noopener\" aria-label=\"remove_action() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/remove_action\/\" target=\"_blank\"><code>remove_action()<\/code><\/a> to call <code>my_get_id()<\/code> which links the avatar to the User with <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/update_user_meta\/\" target=\"_blank\"><code>update_user_meta()<\/code><\/a>.  This works when importing Users or Customers.<\/p>\n\n\n\n<p>The link to each image must be saved in <code>wp_user_avatar<\/code> when importing:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-on-2020-01-01-at-14-55-13-1024x372.png\" alt=\"\" class=\"wp-image-1436\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_import_avatar_image ($id) {\n\n    \/\/ Get the URL for the avatar image.\n    $image_url = get_user_meta($id, \"wp_user_avatar\", true);\n\n    \/\/ Set the my_get_id function to run when attachments added.\n    add_action( 'add_attachment', 'my_get_id' );\n\n    \/\/ Sideload the avatar image.\n    $new_url = media_sideload_image($image_url, $id, null, \"src\");\n\n    \/\/ Remove the my_get_id function from add_attachment action.\n    remove_action( 'add_attachment', 'my_get_id' );\n}\n\nfunction my_get_id( $att_id ) {\n\n    \/\/ Get the post object for the attachment.\n    $img = get_post( $att_id );\n\n    \/\/ Get the attachment's parent.\n    $user = $img-&gt;post_parent;\n\n    \/\/ Set wp_user_avatar to the image's ID.\n    update_user_meta( $user, \"wp_user_avatar\", $att_id );\n}\nadd_action('pmxi_saved_post', 'my_import_avatar_image', 10, 3);<\/code><\/pre><\/div>\n\n\n\n<p>This code has been derived from the following example: <a href=\"http:\/\/wordpress.stackexchange.com\/a\/46365\/108630\">http:\/\/wordpress.stackexchange.com\/a\/46365\/108630<\/a><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-data-to-custom-database-table-during-record-import\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-data-to-custom-database-table-during-record-import\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-data-to-custom-database-table-during-record-import\" class=\"snippet-title\"><h2><strong>Import Data to Custom Database Table<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxi_saved_post (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_saved_post\" target=\"_blank\">pmxi_saved_post<\/a><\/code> action to save data to a custom database table while importing to a defined post type. The value for the custom database table is saved to <code>_your_temp_field<\/code>. Then retrieved using <a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\">get_post_meta()<\/a> and written to the database using the <a rel=\"noreferrer noopener\" aria-label=\"WPDB object (opens in a new tab)\" href=\"https:\/\/codex.wordpress.org\/Class_Reference\/wpdb\" target=\"_blank\">wpdb object<\/a>. To cleanup, we remove the temporary custom field using <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/delete_post_meta\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"delete_post_meta() (opens in a new tab)\">delete_post_meta()<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function save_data_to_custom_database_table($id) {\n    \/\/ Make wpdb object available.\n    global $wpdb;\n\n    \/\/ Retrieve value to save.\n    $value = get_post_meta($id, '_your_temp_field', true);\n\n    \/\/ Define target database table.\n    $table_name = $wpdb-&gt;prefix . \"your_table_name\";\n\n    \/\/ Insert value into database table.\n    $wpdb-&gt;insert($table_name, array('post_id' =&gt; $id, 'column_name' =&gt; $value), array('%s','%s'));\n\n    \/\/ Delete temporary custom field.\n    delete_post_meta($id, '_your_temp_field');\n}\nadd_action('pmxi_saved_post', 'save_data_to_custom_database_table', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#include-featured-image-in-product-gallery-also\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"include-featured-image-in-product-gallery-also\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#include-featured-image-in-product-gallery-also\" class=\"snippet-title\"><h2><strong>Include Featured Image in Product Gallery<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"wp_all_import_variable_product_imported (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_variable_product_imported\" target=\"_blank\">wp_all_import_variable_product_imported<\/a><\/code> action to prepend the featured image to the product's gallery. We use <a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\"><code>get_post_meta()<\/code><\/a> to retrieve current gallery images and <code><a rel=\"noreferrer noopener\" aria-label=\"get_post_thumbnail_id() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_thumbnail_id\/\" target=\"_blank\">get_post_thumbnail_id()<\/a><\/code>for the featured image. It's added to the list of gallery images, duplicates are removed, then <a rel=\"noreferrer noopener\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/update_post_meta\/\" target=\"_blank\"><code>update_post_meta()<\/code><\/a> saves the updates.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function copy_featured_img_to_gallery($post_id) {\n    \n    \/\/ Retrieve the Product Gallery image IDs.\n    $gallery = explode(\",\",get_post_meta($post_id, \"_product_image_gallery\", true));\n\n    \/\/ Add the Featured Image to the Gallery IDs.\n    array_unshift($gallery, get_post_thumbnail_id( $post_id ));\n\n    \/\/ Ensure no image IDs are duplicated in the Gallery.\n    $gallery = array_unique($gallery);\n\n    \/\/ Save the updated list of Gallery image IDs.\n    update_post_meta($post_id, \"_product_image_gallery\", implode(\",\",$gallery));\n\n}\nadd_action('wp_all_import_variable_product_imported', 'copy_featured_img_to_gallery', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#create-one-variation-of-any-for-variable-product\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"create-one-variation-of-any-for-variable-product\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#create-one-variation-of-any-for-variable-product\" class=\"snippet-title\"><h2><strong>List One 'Any Attribute' Variation for Variable Products<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_import_variable_product_imported\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_import_variable_product_imported<\/a><\/code> action to delete all but one variation and set its attributes to 'any'. This may be useful if you have a large number of Attribute options, but each variation's details ( price, stock, etc ) are all the same and don't need to be tracked separately.<\/p>\n\n\n\n<p>The updated products look something like below:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-31-at-09.54.17-1024x406.png\" alt=\"\" class=\"wp-image-1419\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function set_attributes_to_any( $post_parent ){\n    global $wpdb;\n    $table = $wpdb-&gt;posts;\n\n    \/\/ Retrieve all variations for this product.\n    $variations = $wpdb-&gt;get_results(\"SELECT * FROM $table WHERE post_parent = \" . $post_parent );\n    if ( ! empty($variations)){\n\n        \/\/ Keep one variation.\n        $empty_variation = array_shift($variations);\n        if ( ! empty($variations)){\n\n            \/\/ Delete all other variations for this product.\n            foreach($variations as $variation){\n                wp_delete_post($variation-&gt;ID);           \n            }\n        }\n        $table = _get_meta_table('post');\n\n        \/\/ Find all Attributes set for our remaining variation.\n        $post_meta = $wpdb-&gt;get_results(\"SELECT meta_key, meta_value FROM $table WHERE post_id = \" . $empty_variation-&gt;ID . \" AND meta_key LIKE 'attribute%';\" );\n\n        \/\/ Make Attributes show as 'any'.\n        if ( ! empty($post_meta)){\n            foreach ($post_meta as $meta) {\n                update_post_meta($empty_variation-&gt;ID, $meta-&gt;meta_key, '');\n            }\n        }\n    }   \n}\nadd_action( 'wp_all_import_variable_product_imported', 'set_attributes_to_any', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-import-existing-categories-or-other-taxonomy-terms\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-import-existing-categories-or-other-taxonomy-terms\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-import-existing-categories-or-other-taxonomy-terms\" class=\"snippet-title\"><h2><strong>Only Import Existing Taxonomy Terms<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Since version 4.8.2 Beta 1.6 of WP All Import, this snippet is no longer necessary. We've now added the \"Do not create new terms\" option, which can be found inside the Advanced Options of the Taxonomies, Categories, Tags section:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"597\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms-1024x597.png\" alt=\"Do not create new terms\" class=\"wp-image-5818696\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms-1024x597.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms-300x175.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms-768x448.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms-1536x896.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/do-not-create-new-terms.png 1810w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#keep-certain-categories-assigned-even-if-they-do-not-appear-in-your-import-file\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"keep-certain-categories-assigned-even-if-they-do-not-appear-in-your-import-file\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#keep-certain-categories-assigned-even-if-they-do-not-appear-in-your-import-file\" class=\"snippet-title\"><h2><strong>Do Not Remove Certain Categories During Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_set_post_terms\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_set_post_terms (opens in a new tab)\">wp_all_import_set_post_terms<\/a><\/code> filter and <a rel=\"noreferrer noopener\" aria-label=\"get_the_terms() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_the_terms\/\" target=\"_blank\"><code>get_the_terms()<\/code><\/a> to ensure the 'Featured' category remains for any product that had it manually assigned. This allows WP All Import to add and remove other categories without losing our manual assignments.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function dont_remove_featured_category( $term_taxonomy_ids, $tx_name, $pid, $import_id ) {\n\n    \/\/ Only check Product Categories.\n    if ( $tx_name == 'product_cat' ){\n\n        \/\/ Retrieve all currently assigned categories.\n        $txes_list = get_the_terms($pid, $tx_name);\n\n        \/\/ Do nothing if no categories are set.\n        if ( ! empty($txes_list) ){\n           foreach ($txes_list as $cat){\n\n                \/\/ If category name is 'Featured' add it to import.\n                if ($cat-&gt;name == 'Featured'){\n                    $term_taxonomy_ids[] = $cat-&gt;term_taxonomy_id;\n                    break;\n                } \n            }\n        }\n    }\n\n    \/\/ Return the updated list of taxonomies to import.\n    return $term_taxonomy_ids;\n\n}\nadd_filter( 'wp_all_import_set_post_terms', 'dont_remove_featured_category', 10, 4 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#change-delimiter-used-when-retrieving-multiple-elements-with-xpath\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"change-delimiter-used-when-retrieving-multiple-elements-with-xpath\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#change-delimiter-used-when-retrieving-multiple-elements-with-xpath\" class=\"snippet-title\"><h2><strong>Use Custom Delimiter When Retrieving Multiple Values<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_multi_glue\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_multi_glue (opens in a new tab)\">wp_all_import_multi_glue<\/a><\/code> filter to separate multiple returned values with pipes instead of commas.<\/p>\n\n\n\n<p>Here's an example CSV file:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Name<\/td><td>Size<\/td><td>Color<\/td><td>Color<\/td><\/tr><tr><td>Red and Blue Shirt<\/td><td>Medium<\/td><td>Red<\/td><td>Blue<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If we retrieve both Color elements using a single XPath statement such as <code>{Color}<\/code>, by default they will be returned comma-delimited: <code>Red, Blue<\/code><\/p>\n\n\n\n<p>The example code will change that comma to a pipe: <code>Red|Blue<\/code><\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter( 'wp_all_import_multi_glue', function( $delimiter ) {\n    return '|';\n}, 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-custom-field-if-new-value-is-not-empty\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-custom-field-if-new-value-is-not-empty\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-custom-field-if-new-value-is-not-empty\" class=\"snippet-title\"><h2><strong>Only Update Custom Field If New Value Is Not Empty<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_custom_field\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_custom_field (opens in a new tab)\">pmxi_custom_field<\/a><\/code> filter to only overwrite <code>_my_custom_field<\/code> if the new value isn't empty.  This is helpful if the field should always have a value and your file doesn't always provide it.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function keep_existing_if_empty($value, $post_id, $key, $original_value, $existing_meta, $import_id) {\n    \n    \/\/ Only check _my_custom_field.\n    if ($key == '_my_custom_field') {\n\n        \/\/ Check if it has a value.\n        if (empty($value)) {\n\n            \/\/ If empty, use the existing value.\n            $value = isset($original_value) ? $original_value : $value;\n\n        }\n    }\n\n    return $value;\n\n}\nadd_filter('pmxi_custom_field', 'keep_existing_if_empty', 10, 6);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-custom-field-if-its-currently-empty\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-custom-field-if-its-currently-empty\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-custom-field-if-its-currently-empty\" class=\"snippet-title\"><h2><strong>Only Update Custom Field If It's Currently Empty<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_custom_field\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_custom_field (opens in a new tab)\">pmxi_custom_field<\/a><\/code> filter to only update <code>_my_custom_field<\/code> if it's currently empty. This allows for making manual changes to fields that won't be overwritten during import.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function update_existing_if_empty($value, $post_id, $key, $original_value, $existing_meta_keys, $import_id) {\n\n\t\/\/ Only process import ID 1.\n\tif ($import_id == 1) {\n\n\t\t\/\/ Only check _my_custom_field.\n\t\tif ($key == '_my_custom_field') {\n\n\t\t\t\/\/ Check if field exists and if it's empty.\n\t\t\tif (!isset($existing_meta_keys[$key][0]) || empty($original_value)) {\n\n\t\t\t\t\/\/ Use existing value only if currently empty.\n\t\t\t\t$value = $original_value;\n\n\t\t\t}\n\t\t}\n\t}\n\n\treturn $value;\n\n}\nadd_filter('pmxi_custom_field', 'update_existing_if_empty', 10, 6);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-acf-field-value-if-imported-value-is-not-empty\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-acf-field-value-if-imported-value-is-not-empty\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-acf-field-value-if-imported-value-is-not-empty\" class=\"snippet-title\"><h2><strong>Only Update ACF Fields If Imported Values Are Not Empty<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#pmxi_acf_custom_field\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"pmxi_acf_custom_field (opens in a new tab)\">pmxi_acf_custom_field<\/a><\/code> filter and <a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\"><code>get_post_meta()<\/code><\/a> to prevent writing empty values to existing ACF fields.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wp_all_import_pmxi_acf_custom_field( $value, $pid, $name ) { \n\n    \/\/ Retrieve existing ACF field value.\n    $existing = get_post_meta( $pid, $name, true );\n\n    if ( empty( $value ) ) { \n\n        \/\/ If the new value is empty, use existing value.\n        $value = $existing;\n\n    } \n\n    return $value; \n\n}\nadd_filter( 'pmxi_acf_custom_field', 'wp_all_import_pmxi_acf_custom_field', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#filter-posts-by-date\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"filter-posts-by-date\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#filter-posts-by-date\" class=\"snippet-title\"><h2><strong>Filter Posts by Date<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_create (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_create\" target=\"_blank\">wp_all_import_is_post_to_create<\/a><\/code> and <code><a rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_update (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_update\" target=\"_blank\">wp_all_import_is_post_to_update<\/a><\/code> filters to create or update records based on a date in our file. Such code is necessary since the <a rel=\"noreferrer noopener\" aria-label=\"visual filters (opens in a new tab)\" href=\"\/documentation\/advanced\/filtering-with-xpath\/\" target=\"_blank\">visual filters<\/a> won't work with date fields.  <\/p>\n\n\n\n<p>We retrieve the date from <code>column_4<\/code> in our file. Then we specify <code>2018-10-10<\/code> as our target date before converting it to a Unix timestamp. We include those newer than our target date in the import.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function filter_by_date( $continue_import, $data, $param3, $param4 = null ) {\n\n    \/\/ Determine available parameters.\n    if( $param4 === null ){ \/\/ wp_all_import_is_post_to_create\n        $import_id = $param3;\n    }else{ \/\/ wp_all_import_is_post_to_update\n        $import_id = $param4;\n        $data = $param3;\n    }\n\n    \/\/ Only apply to import ID 3\n    if ( $import_id == 3 ) {\n\n        \/\/ Change 'column_4' to your file's date field.\n        $date_in_file = strtotime( $data['column_4'] );\n\n        \/\/ Change '2018-10-10' to your real target date.\n        $date = \"2018-10-10\";\n\n        \/\/ Convert specified date to Unix timestamp.\n        $target_date = strtotime($date);\n\n        \/\/ Compare file date with target date.\n        if ( $date_in_file &gt;= $target_date ) {\n\n            \/\/ Create or update record if file date &gt;= target date.\n            return true;\n\n        } else {\n\n            \/\/ Do not create or update the record otherwise.\n            return false;\n\n        }\n    }\n\n    \/\/ Take no action for other import IDs.\n    return $continue_import;\n\n}\n\n\/\/ Apply the code to posts set to be created.\nadd_filter('wp_all_import_is_post_to_create', 'filter_by_date', 10, 3);\n\n\/\/ Apply the code to posts set to be updated.\nadd_filter('wp_all_import_is_post_to_update', 'filter_by_date', 10, 4);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-create-a-post-if-an-existing-post-doesnt-have-the-same-custom-field-value\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-create-a-post-if-an-existing-post-doesnt-have-the-same-custom-field-value\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-create-a-post-if-an-existing-post-doesnt-have-the-same-custom-field-value\" class=\"snippet-title\"><h2><strong>Only Create Post If Custom Field Value Is Unique<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_create\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_create (opens in a new tab)\">wp_all_import_is_post_to_create<\/a><\/code> filter to only create records if they have a unique value for <code>my_custom_field<\/code>. This prevents duplicates when importing overlapping records using multiple 'New Items' imports.  We use <a rel=\"noreferrer noopener\" aria-label=\"WP_Query (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/\" target=\"_blank\"><code>WP_Query<\/code><\/a> to check for existing posts with the same value.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function create_only_if_unique_custom_field( $continue_import, $data, $import_id ) {\n    \/\/ Only run for import ID 1.\n    if ($import_id == 1) {\n\n        \/\/ The custom field to check.\n    \t$key_to_look_up = \"my_custom_field\";\n\n        \/\/ The value to check where 'num' is the element name.\n    \t$value_to_look_up = $data['num'];\n\n        \/\/ Prepare the WP_Query arguments\n        $args = array (\n\n            \/\/ Set the post type being imported.\n            'post_type'  =&gt; array( 'post' ),\n\n            \/\/ Check our custom field for our value.\n            'meta_query' =&gt; array(array(\n            'key'        =&gt; $key_to_look_up,\n            'value'      =&gt; $value_to_look_up,\n            )),\n        );\n\n        \/\/ Run the query and do not create post if custom\n        \/\/ field value is duplicated.\n\t$query = new WP_Query( $args );\n\treturn !($query-&gt;have_posts());\n\n    } else {\n\n        \/\/ Take no action if a different import ID is running.\n       return $continue_import;\n\n    }\n}\nadd_filter('wp_all_import_is_post_to_create', 'create_only_if_unique_custom_field', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#do-not-create-products-with-duplicate-sku\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"do-not-create-products-with-duplicate-sku\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#do-not-create-products-with-duplicate-sku\" class=\"snippet-title\"><h2><strong>Do Not Create Products With Duplicate SKU<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_create\">wp_all_import_is_post_to_create<\/a><\/code> filter to avoid creating products with duplicate SKUs. This helps when the same product may appear in multiple 'New Items' imports. For fields other than SKU use <a href=\"\/documentation\/developers\/code-snippets\/#only-create-a-post-if-an-existing-post-doesnt-have-the-same-custom-field-value\">this snippet<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function dont_duplicate_skus( $continue_import, $data, $import_id ) {\n\t\n    \/\/ Get the SKU from the import file.\n    \/\/ Change 'sku' to the column name that contains your SKU.\n    $sku = $data['sku'];\n    \n    \/\/ Enable access to global wpdb object.\n    global $wpdb;\n\n    \/\/ Check if the SKU already exists.\n    $product_id = $wpdb-&gt;get_var( $wpdb-&gt;prepare( \"SELECT post_id FROM $wpdb-&gt;postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1\", $sku ) );\n\t\n    if ( $product_id ) {\n\n        \/\/ If product ID exists then skip importing.\n        return false;\n\n    } else {\n\n        \/\/ Else, import the product.\n        return true;\n\n    }\n}\nadd_filter('wp_all_import_is_post_to_create', 'dont_duplicate_skus', 10, 3);<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-posts-that-are-set-as-draft\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-posts-that-are-set-as-draft\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-posts-that-are-set-as-draft\" class=\"snippet-title\"><h2><strong>Only Update Posts with a Specific Status<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_update (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_update\" target=\"_blank\">wp_all_import_is_post_to_update<\/a><\/code> filter to only update records that are set to 'draft'. We use <a rel=\"noreferrer noopener\" aria-label=\"get_post_status() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_status\/\" target=\"_blank\"><code>get_post_status()<\/code><\/a> to retrieve the current status of each record to determine if it should be updated.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_check_post_status ($continue_import, $post_id, $data, $import_id ) {\n\n    \/\/ Only process import ID 1.\n    if ($import_id == 1) {\n\n\t\/\/ Retrieve post status.\n\t$my_post_status = get_post_status($post_id);\n\n\t\/\/ Check if status is set to draft.\n        if ($my_post_status == \"draft\") {\n\n            \/\/ Tell WP All Import to update post if it's draft.\n            return true;\n        }\n\n        \/\/ Do not update post if it's not set to draft.\n        return false;\n\n    }\n    else {\n\n        \/\/ Do nothing if it's not our specified import ID.\n        return $continue_import;\n\n    }\n}\nadd_filter( 'wp_all_import_is_post_to_update', 'my_check_post_status', 10, 4 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-products-with-a-different-stock-status-in-the-import-file\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-products-with-a-different-stock-status-in-the-import-file\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-products-with-a-different-stock-status-in-the-import-file\" class=\"snippet-title\"><h2><strong>Only Update Products If The Stock Status Changed<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_update\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_update (opens in a new tab)\">wp_all_import_is_post_to_update<\/a><\/code> filter and <a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\"><code>get_post_meta<\/code><\/a> to compare each product's <code>_stock_status<\/code> with the status in our file. If they match the product won't be updated.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function only_update_if_stock_status_changed ( $continue_import, $post_id, $data, $import_id ) {\n\n    \/\/ Only run for import ID 1.\n    if ($import_id == 1) {\n\n        \/\/ Get stock status from the import file.\n        \/\/ Our file element is named 'stock_status'.\n        $import_stock_status = $data[\"stock_status\"];\n\n        \/\/ Retrieve product's current stock status.\n        $woo_stock_status = get_post_meta($post_id, \"_stock_status\", true);\n\n        \/\/ Check if import_stock_status and\n        \/\/ woo_stock_status match.\n        if ($import_stock_status !== $woo_stock_status) {\n\n            \/\/ Update the product if they don't.\n            return true;\n\n        }else{\n            \/\/ Otherwise, don't update the product.\n            return false;\n        }\n    }\n\n    \/\/ Do nothing if it's not our target import.\n    return $continue_import;\n\n}\nadd_filter( 'wp_all_import_is_post_to_update', 'only_update_if_stock_status_changed', 10, 4 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-update-product-if-price-was-not-manually-changed\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-update-product-if-price-was-not-manually-changed\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-update-product-if-price-was-not-manually-changed\" class=\"snippet-title\"><h2><strong>Only Update Product If Price Was Not Manually Changed<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_update\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_update (opens in a new tab)\">wp_all_import_is_post_to_update<\/a><\/code> filter and <a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\"><code>get_post_meta()<\/code><\/a> to check if <code>_last_imported_price<\/code> matches the currently set price. This prevents updating the product if the price was manually changed. The <code>_last_imported_price<\/code> custom field must be set to your price element:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-on-2020-01-03-at-13-59-13-1024x339.png\" alt=\"\" class=\"wp-image-1461\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function do_not_update_if_price_hand_modified( $continue_import, $post_id, $data, $import_id ) {\n\n    \/\/ Only run for import ID 1.\n    if ($import_id == 1) {\n\n        \/\/ Retrieve last imported price.\n        $imported_price = get_post_meta($post_id, \"_last_imported_price\", true);\n\n        \/\/ If price isn't greater than zero update the product.\n        if ($imported_price &lt;= 0) \n            return true;\n\n        \/\/ Update product if the new prices matches that \n        \/\/ last imported.\n        if ($imported_price === get_post_meta($post_id, \"_price\", true)) \n            return true;\n\n        \/\/ Do not update product otherwise.\n        return false;\n    }\n\n    else {\n\n        \/\/ Take no action if it's not our import ID.\n        return $continue_import;\n\n    }\n}\nadd_filter( 'wp_all_import_is_post_to_update', 'do_not_update_if_price_hand_modified', 10, 4 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#delete-orphaned-variations-when-deleting-parent-product\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"delete-orphaned-variations-when-deleting-parent-product\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#delete-orphaned-variations-when-deleting-parent-product\" class=\"snippet-title\"><h2><strong>Delete Orphaned Variations When Deleting Previously Imported Products<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_delete (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_delete\" target=\"_blank\">wp_all_import_is_post_to_delete<\/a><\/code> filter to only delete variations created by WP All Import that have been orphaned. This is needed as our import file won't always list all of the variations. Also, we need to make sure we don't leave orphaned variations after deleting a parent product. The 'Delete products that are no longer present in your file' option must be checked or the code does nothing (Manage Imports &gt; Import Settings).<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function is_post_to_delete_orphans($to_delete, $pid, $import) {\n    \n    \/\/ Only process products.\n    if ($import-&gt;options['custom_type'] == 'product') {\n\n        \/\/ Retried product post object.\n        $post_to_delete = get_post($pid);\n\n        \/\/ Check if parent or variation.\n        switch ($post_to_delete-&gt;post_type) {\n\n            \/\/ Mark to delete if parent.\n            case 'product':\n                $to_delete = true;\n                break;\n\n            \/\/ Process variations.\n            case 'product_variation':\n                $parent_product = get_post($post_to_delete-&gt;post_parent);\n\n                \/\/ Only delete variation if orphaned.\n                $to_delete = empty($parent_product) ? true : false;\n                break;\n        }\n    }\n\n    return $to_delete;\n\n}\nadd_filter('wp_all_import_is_post_to_delete', 'is_post_to_delete_orphans', 11, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#prevent-some-posts-from-being-deleted-by-wp-all-import\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"prevent-some-posts-from-being-deleted-by-wp-all-import\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#prevent-some-posts-from-being-deleted-by-wp-all-import\" class=\"snippet-title\"><h2><strong>Prevent Some Posts From Being Deleted By WP All Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_is_post_to_delete\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_is_post_to_delete (opens in a new tab)\">wp_all_import_is_post_to_delete<\/a><\/code> filter and <code><a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\">get_post_meta()<\/a><\/code> to avoid deleting records that have a <code>do_not_delete<\/code> custom field. This allows manually specifying that some products should not be deleted even if they're missing from your file.  <\/p>\n\n\n\n<p>It only works when using the 'Delete products that are no longer present in your file' option (Step 4 or Manage Imports &gt; Import Settings).<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function is_post_to_delete_on_meta($is_post_to_delete, $pid, $import) {\n    \/\/ Check if a custom field named 'do_not_delete' exists and\n    \/\/ do not delete record if it does.\n    return $var =  ( get_post_meta($pid, 'do_not_delete', true) ) ? false : true;\n}\nadd_filter('wp_all_import_is_post_to_delete', 'is_post_to_delete_on_meta', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#save-images-to-your-themes-or-plugins-custom-gallery\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"save-images-to-your-themes-or-plugins-custom-gallery\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#save-images-to-your-themes-or-plugins-custom-gallery\" class=\"snippet-title\"><h2><strong>Save Images To Your Theme's or Plugin's Custom Gallery<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxi_gallery_image (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxi_gallery_image\" target=\"_blank\">pmxi_gallery_image<\/a><\/code> action to add images to a few common gallery field configurations. We use <code><a rel=\"noreferrer noopener\" aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\">get_post_meta()<\/a><\/code> to retrieve the existing gallery fields and <code><a rel=\"noreferrer noopener\" aria-label=\"update_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/update_post_meta\/\" target=\"_blank\">update_post_meta()<\/a><\/code> to save the new updated galleries. When working with named key arrays we use <code><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_get_attachment_image_src\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_get_attachment_image_src() (opens in a new tab)\">wp_get_attachment_image_src()<\/a><\/code> to retrieve the image URLs.<\/p>\n\n\n\n<p>We import our images using the Images section (Step 3 or Manage Imports &gt; Edit Import). <\/p>\n\n\n\n<p><strong>Named Key Arrays (<\/strong><code><strong>[image_id_1 =&gt; \"image_url_1\"]<\/strong><\/code><strong>):<\/strong><\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function gallery_id_url($post_id, $att_id, $filepath, $is_keep_existing_images = '') {\n\n    \/\/ The custom field used by the gallery.\n    $key = '_gallery';\n\n    \/\/ The image size to list in the gallery.\n    $size = 'full';     \n\n    \/\/ Retrieve the current gallery value.\n    $gallery = get_post_meta($post_id, $key, TRUE);\n\n    \/\/ If it's empty declare a new array.\n    if (empty($gallery)) {\n        $gallery = array();\n    }\n\n    \/\/ Check if image is already in the gallery.\n    if (!isset($gallery[$att_id])) {\n\n        \/\/ If not, retrieve the image's URL.\n        $src = wp_get_attachment_image_src($att_id, $size);\n\n        \/\/ Add the image ID and URL to our gallery.\n        $gallery[$att_id] = $src[0];\n\n        \/\/ Save the gallery.\n        update_post_meta($post_id, $key, $gallery);\n\n    }\n}\nadd_action('pmxi_gallery_image', 'gallery_id_url', 10, 4);<\/code><\/pre><\/div>\n\n\n\n<p><strong>Numeric Array Keys (<\/strong><code><strong>[0 =&gt; image_id_1, 1 =&gt; image_id_2]<\/strong><\/code><strong>):<\/strong><\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function gallery_n_id($post_id, $att_id, $filepath, $is_keep_existing_images = '') {\n    \n    \/\/ The custom field used for the gallery.\n    $key = '_gallery';  \n\n    \/\/ Retrieve existing gallery values.\n    $gallery = get_post_meta($post_id, $key, TRUE);\n\n    \/\/ If gallery is empty declare a new array.\n    if (empty($gallery)) {\n        $gallery = array();\n    }\n\n    \/\/ Check if the image is in the gallery.\n    if (!in_array($att_id, $gallery)) {\n\n        \/\/ If not, add it.\n        $gallery[] = $att_id;\n\n        \/\/ Save the new gallery.\n        update_post_meta($post_id, $key, $gallery);\n\n    }\n}\nadd_action('pmxi_gallery_image', 'gallery_n_id', 10, 4);<\/code><\/pre><\/div>\n\n\n\n<p><strong>Individual Post Meta (custom field) per image:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function gallery_meta_id($post_id, $att_id, $filepath, $is_keep_existing_images = '') {\n    \n    \/\/ The custom field used for the gallery.\n    $key = '_gallery'; \/\/ Edit this: Set meta key for gallery array here\n\n    \/\/ Retrieve the current gallery values.\n    $result = get_post_meta($post_id, $key, FALSE);\n\n    \/\/ Check if the image is already in the gallery.\n    if (is_array($result)) {\n\n        \/\/ If not, add it.\n        if (!in_array($att_id, $result)) {\n            add_post_meta($post_id, $key, $att_id);\n        }\n\n    }\n}\nadd_action('pmxi_gallery_image', 'gallery_meta_id', 10, 4);<\/code><\/pre><\/div>\n\n\n\n<p><strong>Comma-separated image IDs (23,25,31):<\/strong><\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function gallery_ids_in_string($post_id, $att_id, $filepath, $is_keep_existing_images = '') {\n    \/\/ The custom field used by gallery.\n    $key = '_gallery';\n\n    \/\/ The separator to use between each ID.\n    $separator = \",\";\n\n    \/\/ Retrieve the current values in the gallery field.\n    $gallery = get_post_meta($post_id, $key, true);\n\n    \/\/ Ensure gallery is valid.\n    if (is_string($gallery) || is_empty($gallery) || ($gallery == false)) {\n\n        \/\/ Split value into array.\n        $gallery = explode($separator, $gallery);\n\n        \/\/ Add image if it's not in the gallery.\n        if (!in_array($att_id, $gallery)) {\n\n            \/\/ Ensure array doesn't start with empty value.\n            if ($gallery[0] == '') unset($gallery[0]);\n\n            \/\/ Add image ID to array.\n            $gallery[] = $att_id;\n\n            \/\/ Save updated gallery field.\n            update_post_meta($post_id, $key, implode($separator, $gallery));\n\n        }\n    }\n}\nadd_action('pmxi_gallery_image', 'gallery_ids_in_string', 10, 4);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#save-imported-images-to-a-custom-folder\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"save-imported-images-to-a-custom-folder\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#save-imported-images-to-a-custom-folder\" class=\"snippet-title\"><h2><strong>Save Imported Images To A Custom Folder<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_import_images_uploads_dir\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_import_images_uploads_dir<\/a><\/code> filter to save our images to the <code>uploads\/customfolder<\/code> directory. This can prevent saving a large number of images in a single folder when they're imported the same day.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpai_set_custom_upload_folder($uploads, $articleData, $current_xml_node, $import_id) {\n\n    \/\/ Change our upload path to uploads\/customfolder.\n    $uploads['path'] = $uploads['basedir'] . '\/customfolder';\n    $uploads['url'] = $uploads['baseurl'] . '\/customfolder';    \n    \n    \/\/ Check if the target directory exists.\n    if (!file_exists($uploads['path'])) {\n\n        \/\/ If not, create the directory.\n        mkdir($uploads['path'], 0755, true);\n\n    }\n\n    return $uploads;\n\n}\nadd_filter('wp_all_import_images_uploads_dir', 'wpai_set_custom_upload_folder', 10, 4);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#apply-wp_handle_upload-filter-to-uploaded-attachments-and-filters\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"apply-wp_handle_upload-filter-to-uploaded-attachments-and-filters\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#apply-wp_handle_upload-filter-to-uploaded-attachments-and-filters\" class=\"snippet-title\"><h2><strong>Apply wp_handle_upload Filter to Uploaded Files<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_import_handle_upload\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_import_handle_upload (opens in a new tab)\">wp_all_import_handle_upload<\/a><\/code> to apply the <a rel=\"noreferrer noopener\" aria-label=\"wp_handle_upload (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/hooks\/wp_handle_upload\/\" target=\"_blank\"><code>wp_handle_upload<\/code><\/a> filter to all imported attachments and images.  It's normally fired when uploading files to WordPress. However, it's disabled during imports to increase speed. Firing this filter allows plugins such as <a rel=\"noreferrer noopener\" aria-label=\"Imsanity (opens in a new tab)\" href=\"https:\/\/wordpress.org\/plugins\/imsanity\/\" target=\"_blank\">Imsanity<\/a> to work for imported files.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter('wp_all_import_handle_upload', function( $file ){\n\n    return apply_filters( 'wp_handle_upload', $file, 'upload');\n\n}, 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#set-order-to-complete-after-order-is-exported\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"set-order-to-complete-after-order-is-exported\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#set-order-to-complete-after-order-is-exported\" class=\"snippet-title\"><h2><strong>Set Exported Order Status<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\"pmxe_exported_post (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxe_exported_post\" target=\"_blank\" rel=\"noreferrer noopener\">pmxe_exported_post<\/a><\/code> action to mark exported Orders as completed. We use the <code><a href=\"https:\/\/woocommerce.github.io\/code-reference\/classes\/WC-Order.html\" target=\"_blank\" rel=\"noreferrer noopener\">WC_Order<\/a><\/code> method <code><a href=\"https:\/\/woocommerce.github.io\/code-reference\/classes\/WC-Order.html#method_update_status\" target=\"_blank\" rel=\"noreferrer noopener\">update_status()<\/a><\/code> which can set any desired order status.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function set_order_status_on_export($post_id, $exportObject) {\n\n    \/\/ Retrieve export ID. \n    $export_id = ( isset( $_GET['id'] ) ? $_GET['id'] : ( isset( $_GET['export_id'] ) ? $_GET['export_id'] : 'new' ) );\n\n    \/\/ Only run for export 1.\n    if ($export_id == \"1\") {\n\n        \/\/ Retrieve Order object.\n&nbsp; &nbsp; &nbsp; &nbsp; $order = new WC_Order($post_id);\n\n        \/\/ Set Order status to completed.\n&nbsp; &nbsp; &nbsp; &nbsp; $order-&gt;update_status('completed', 'export_completed'); \n\n&nbsp; &nbsp; &nbsp;}\n}\nadd_action('pmxe_exported_post', 'set_order_status_on_export', 10, 2);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#dont-export-variations-to-gmc-when-parent-set-to-draft\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"dont-export-variations-to-gmc-when-parent-set-to-draft\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#dont-export-variations-to-gmc-when-parent-set-to-draft\" class=\"snippet-title\"><h2><strong>Filter Variations by Parent Status When Exporting to GMC<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\"wp_all_export_csv_rows (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#wp_all_export_csv_rows\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_export_csv_rows<\/a><\/code> filter to only export variations whose parents are not set to 'draft', and only export products in other product types that are not drafts. This is especially useful for Google Merchant Center exports as they apply <code>Status<\/code> filters directly to variations by default.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function exclude_products_from_gmc_export( $articles, $options, $export_id ) {\n\n    \/\/ Target GMC exports only\n    if ( $options['xml_template_type'] !== 'XmlGoogleMerchants' ) {\n        return $articles;\n    }\n\n    \/\/ Iterate through exported products\n    foreach ( $articles as $key => $article ) {\n\n        if ( ! empty( $article['id'] ) ) {\n            $post_id = $article['id'];\n            $parent_id = wp_get_post_parent_id( $post_id );\n\n            \/\/ Check for draft status (both product and parent)\n            if ( get_post_status( $post_id ) === 'draft' || \n                 ( $parent_id &amp;&amp; get_post_status( $parent_id ) === 'draft' ) ) {\n\n                unset( $articles[ $key ] ); \n            }\n        }\n    }\n\n    \/\/ Ensure proper array return \n    return ! empty( $articles ) ? $articles : []; \n}\nadd_filter( 'wp_all_export_csv_rows', 'exclude_products_from_gmc_export', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#only-export-records-to-csv-based-on-date\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"only-export-records-to-csv-based-on-date\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#only-export-records-to-csv-based-on-date\" class=\"snippet-title\"><h2><strong>Limit Records Exported to CSV by Date<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_export_csv_rows\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_export_csv_rows<\/a><\/code> filter to export only records where <code>_my_time<\/code> is older than tomorrow. This helps when you need more control than the visual filters offer. The example works for CSV, Excel, and Google Merchant Center exports only. You must include <code>_my_time<\/code> when configuring the export.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function filter_export_by_date($articles, $options, $export_id) {\n\n    \/\/ Process each record to be exported.\n    foreach ($articles as $key =&gt; $article) {\n\n        \/\/ Set target date as Unix timestamp.\n        $target_date = strtotime(\"tomorrow\");\n\n        \/\/ Convert _my_time element's time to Unix timestamp.\n        $my_time = strtotime($article[\"_my_time\"]);\n\n        \/\/ Check if $my_time is older that $target_date\n        if ($my_time &lt; $target_date) {\n\n            \/\/ Do not export records older than $target_date.\n            unset($articles[$key]);\n\n        }\n    }\n    \/\/ Return updated array of records to export.\n    return isset($articles[0]) ? $articles : $articles[0] = [];\n}\nadd_filter('wp_all_export_csv_rows', 'filter_export_by_date', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#limit-number-of-records-exported-when-exporting-to-xml\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"limit-number-of-records-exported-when-exporting-to-xml\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#limit-number-of-records-exported-when-exporting-to-xml\" class=\"snippet-title\"><h2><strong>Limit Number of Records Exported When Exporting to XML<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_export_xml_rows\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_export_xml_rows (opens in a new tab)\">wp_all_export_xml_rows<\/a><\/code> filter to limit the number of records exported to XML.  We use <a rel=\"noreferrer noopener\" aria-label=\"get_posts() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_posts\/\" target=\"_blank\"><code>get_posts()<\/code><\/a> to handle retrieving only the records we want to export.  Our example further limits exported records to those with a specific taxonomy term set.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter('wp_all_export_xml_rows', function($shouldExport, $record, $exportOptions, $exportId) {\n\n    \/\/ The Export ID to be filtered.\n    $exportToApplyFilterTo = 3;\n\n    \/\/ The number of records to be exported.\n    $lastNumberOfPostsToExport = 200;\n\n    \/\/ Do nothing if it's not our defined export ID running.\n    if($exportId == $exportToApplyFilterTo) {\n\n        \/\/ Retrieve the records we want to export.\n        $posts = get_posts(\n            array(\n            'numberposts' =&gt; $lastNumberOfPostsToExport,\n\n            \/\/ Only export published records.\n            'post_status' =&gt; 'publish',\n\n            \/\/ START TAXONOMY QUERY, REMOVE IF NOT FILTERING BY TAXONOMY\n            'tax_query' =&gt; array(\n                array(\n\n                    \/\/ The taxonomy to check.\n                    'taxonomy' =&gt; 'property_status',\n\n                    \/\/ Search by Term ID.\n                    'field' =&gt; 'term_id',\n\n                    \/\/ The term_id of the taxonomy term.\n                    'terms' =&gt; 575,\n                    'include_children' =&gt; false\n                )\n            ),\n            \/\/ END TAXONOMY QUERY\n\n            'fields' =&gt; 'ids',\n            'order' =&gt; 'desc',\n            'orderby' =&gt; 'ID',\n            'post_type' =&gt; $record-&gt;post_type\n            )\n        );\n\n        \/\/ Only export records found by get_posts() above.\n        if(in_array($record-&gt;ID, $posts)) {\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    \/\/ Do nothing if our defined export ID isn't running.\n    return $shouldExport;\n}, 11, 4);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#add-custom-line-endings-to-csv-export-file\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"add-custom-line-endings-to-csv-export-file\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#add-custom-line-endings-to-csv-export-file\" class=\"snippet-title\"><h2><strong>Append Custom Line Endings to Export File<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_export_after_csv_line\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_export_after_csv_line (opens in a new tab)\">wp_all_export_after_csv_line<\/a><\/code> filter to append a newline character to each row in our CSV file during export. <\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function custom_line_ending( $stream, $export_id ){\n    \/\/ Define character for line ending.\n    fwrite( $stream, \"n\" );\n    return $stream;\n}\nadd_filter( 'wp_all_export_after_csv_line', 'custom_line_ending', 10, 2 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#programmatically-add-elements-to-xml-exports\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"programmatically-add-elements-to-xml-exports\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#programmatically-add-elements-to-xml-exports\" class=\"snippet-title\"><h2><strong>Programmatically Add Elements To XML Exports<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"\/documentation\/advanced\/action-reference\/#wp_all_export_additional_data\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"wp_all_export_additional_data (opens in a new tab)\">wp_all_export_additional_data<\/a><\/code> filter to add an element named <code>created_at<\/code> to our exported XML file.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpae_additional_data_field($add_data, $options) {\n    \/\/ Add 'created_at' element and set its value to\n    \/\/ the current date and time.\n    $add_data['created_at'] = date(\"Y-m-d H:i:s\");\n    return $add_data;\n}\nadd_filter('wp_all_export_additional_data', 'wpae_additional_data_field', 10, 2);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#move-export-file-after-export\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"move-export-file-after-export\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#move-export-file-after-export\" class=\"snippet-title\"><h2><strong>Move Generated File After Export<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxe_after_export (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxe_after_export\" target=\"_blank\">pmxe_after_export<\/a><\/code> action to move our export file to <code>\/wp-content\/uploads<\/code>. The <a rel=\"noreferrer noopener\" aria-label=\"get_attached_file() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_attached_file\/\" target=\"_blank\"><code>get_attached_file()<\/code><\/a> function allows us to retrieve the export file path when Secure Mode is enabled. The WordPress uploads directory is located using <a rel=\"noreferrer noopener\" aria-label=\"wp_get_upload_dir() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_get_upload_dir\/\" target=\"_blank\"><code>wp_get_upload_dir()<\/code><\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function move_export_file ($export_id, $exportObj) {\n\t\n    \/\/ Get WordPress's upload directory.\n    $upload_dir = wp_get_upload_dir();\n\t\n    \/\/ Check whether \"Secure Mode\" is enabled in All Export &gt; Settings\n    $is_secure_export = PMXE_Plugin::getInstance()-&gt; getOption('secure');\n\t\n\n    if ( !$is_secure_export ) {\n\n        \/\/ Get filepath when 'Secure Mode' is off.\n        $filepath = get_attached_file($exportObj-&gt;attch_id);\n                    \n    } else {\n\n        \/\/ Get filepath with 'Secure Mode' on.\n        $filepath = wp_all_export_get_absolute_path($exportObj-&gt;options['filepath']);\n\n    }\n\t\n    \/\/ Get the filename.\n    $filename = basename( $filepath );\n\t\n    \/\/ Move export file into \/wp-content\/uploads.\n    rename( $filepath,  $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $filename );\n\n}\nadd_action('pmxe_after_export', 'move_export_file', 10, 2);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#run-cron-export-with-only-a-trigger-cron-job\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"run-cron-export-with-only-a-trigger-cron-job\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#run-cron-export-with-only-a-trigger-cron-job\" class=\"snippet-title\"><h2><strong>Run Cron Export With Only A Trigger Cron Job and 1 Processing Cron Job<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a rel=\"noreferrer noopener\" aria-label=\"pmxe_after_iteration (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxe_after_iteration\" target=\"_blank\">pmxe_after_iteration<\/a><\/code> action to avoid the need for multiple 'processing' cron jobs. However, if something fails on one of the iterations the export will hang. It will also hang if the process calling the 'trigger' or 'processing' URL closes the connection before the export is complete.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpae_continue_cron( $export_id, $exportObj ) {\n\n    \/\/ Only run for export ID 12.\n    if ( $export_id == '12' ) {\n\n        \/\/ Import 12's 'processing' URL. \n        $cron_processing_url = 'http:\/\/lame-addax-cat.w6.wpsandbox.pro\/wp-cron.php?export_key=g99mni1B6Kpu&amp;export_id=12&amp;action=processing';\n\n        \/\/ Redirect the connection to the 'processing' URL.\n        header( \"Location: \" .  $cron_processing_url . \"\" );\n    }\n}\nadd_action( 'pmxe_after_iteration', 'wpae_continue_cron', 10, 2 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#add-password-to-imported-post\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"add-password-to-imported-post\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#add-password-to-imported-post\" class=\"snippet-title\"><h2><strong>Set Password for Imported Posts<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#pmxi_saved_post\">pmxi_saved_post<\/a><\/code> action to set the password for each post as it's imported. In this case, our posts all have a different password, each defined in the import file:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2019-12-22-at-11.22.15-AM-1024x274.png\" alt=\"\" class=\"wp-image-1365\"\/><\/figure>\n\n\n\n<p>Every time a post is successfully imported or updated our code will retrieve the custom field's value with <code><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\">get_post_meta()<\/a><\/code> and pass it to <code><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_update_post\/\">wp_update_post()<\/a><\/code>, which will actually set the passwords.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function set_post_password( $pid ) {\n    wp_update_post( array(\n\n        \/\/ Specify post to update.\n        'ID' =&gt; $pid,\n\n        \/\/ Set password to value of custom field.\n        'post_password' =&gt; get_post_meta( $pid, '_password', true )\n  &nbsp; ) );\n}\nadd_action( 'pmxi_saved_post', 'set_post_password', 10, 1 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#use-import-id-in-the-import-template\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"use-import-id-in-the-import-template\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#use-import-id-in-the-import-template\" class=\"snippet-title\"><h2><strong>Retrieve Import ID for Use in Template<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use some custom code to retrieve the import ID. It can be saved to a custom field to track the records updated by each import. Also, the <code>$import_id<\/code> definition can be used with our various hooks that don't provide the Import ID as a parameter.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function get_import_id() {\n    \/\/ Retrieve the import ID while the import is running.\n    $import_id = wp_all_import_get_import_id(); \n    return $import_id;\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#comma-separated-data-to-serialized-array\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"comma-separated-data-to-serialized-array\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#comma-separated-data-to-serialized-array\" class=\"snippet-title\"><h2><strong>Convert Comma-separated List into Serialized Array<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use custom code to convert our list element's value into a serialized array. Our theme requires this field to only contain serialized values.<\/p>\n\n\n\n<p>Original value: <code>red, green, blue, yellow<\/code><\/p>\n\n\n\n<p>Value after our code: <code>a:4:{i:0;s:3:\"red\";i:1;s:6:\" green\";i:2;s:5:\" blue\";i:3;s:7:\" yellow\";}<\/code><\/p>\n\n\n\n<p>We call the code like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-09-at-14.57.17-1024x294.png\" alt=\"\" class=\"wp-image-1545\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function list_to_serialized( $value ) {\n    \/\/ Split the list at the commas.\n    $value = explode(',', $value);\n    \/\/ Return the serialized list.\n    return serialize( $value );\n}<\/code><\/pre><\/div>\n\n\n\n<p><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#generate-taxonomy-hierarchy-using-child-taxonomies\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"generate-taxonomy-hierarchy-using-child-taxonomies\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#generate-taxonomy-hierarchy-using-child-taxonomies\" class=\"snippet-title\"><h2><strong>Generate Taxonomy Hierarchy from Child Terms<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we generate a full taxonomy hierarchy for each of our terms using custom code. Our import file only contains the child terms and we don't yet have the full hierarchy on our site.<\/p>\n\n\n\n<p>The field with our terms looks like this:<br><code>2.1.1. | 2.1.4. | 2.1.5. | 3.1.1. | 3.1.2.<\/code><\/p>\n\n\n\n<p>Our code takes our element's value and outputs the hierarchical version:<br><code>2.&gt;2.1.&gt;2.1.1. | 2.&gt;2.1.&gt;2.1.4. | 2.&gt;2.1.&gt;2.1.5. | 3.&gt;3.1.&gt;3.1.1. | 3.&gt;3.1.&gt;3.1.2.<\/code><\/p>\n\n\n\n<p>We must configure our import to accept that hierarchical string:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-09-at-16.03.53-1024x563.png\" alt=\"\" class=\"wp-image-1550\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function get_hierarchy_taxonomies( $tax_str ) {\n\n    \/\/ Convert our list of terms to an array.\n    $tax_array = explode(\"|\", $tax_str);\n\n    \/\/ Process each term.\n    foreach( $tax_array as $val ){\n\n        \/\/ Generate the top level term.\n    \t$temp = substr( trim( $val ), 0, 2 ) . '>'\n\n        \/\/ Generate the second level term. \n        $temp .= substr( trim( $val ), 0, 4 ) . '>'\n\n        \/\/ Add the original term to the hierarchy.\n        $temp .= trim( $val );\n\n    }\n    \/\/ Return our updated term hierarchies separated by pipes.\n    return implode( \"|\", $tax_hierarchy_array );\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#update-only-selected-records\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"update-only-selected-records\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#update-only-selected-records\" class=\"snippet-title\"><h2><strong>Prevent Certain Records from Being Updated<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_import_is_post_to_update\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_import_is_post_to_update<\/a><\/code> filter to prevent updating records we've manually modified. This is accomplished by setting the <code>do_not_update<\/code> custom field on any record we don't want to update. We use <code><a aria-label=\"get_post_meta() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_post_meta\/\" target=\"_blank\" rel=\"noreferrer noopener\">get_post_meta()<\/a><\/code> to check if <code>do_not_update<\/code> exists. If it does, we tell WP All Import not to update that record by returning <code>false<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function is_post_to_update( $continue_import, $pid ) { \n    \/\/ Retrieve custom field value.\n    $do_not_update = get_post_meta( $pid, 'do_not_update', true ); \n    \/\/ Update post if do_not_update field not set.\n    return ( !empty( $do_not_update ) ) ? false : $continue_import; \n\n}\nadd_filter( 'wp_all_import_is_post_to_update', 'is_post_to_update', 10, 2 );  <\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#image-for-property-themes\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"image-for-property-themes\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#image-for-property-themes\" class=\"snippet-title\"><h2><strong>Bulk Attach Images to a Record's Custom Gallery<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_saved_post<\/a><\/code> action to link all of our images for each property at once. This can be faster than using <code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#pmxi_gallery_image\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_gallery_image<\/a><\/code> when there are many images per property (or any other post type using custom galleries).<\/p>\n\n\n\n<p>The <code><a rel=\"noreferrer noopener\" aria-label=\"get_attached_media() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_attached_media\/\" target=\"_blank\">get_attached_media()<\/a><\/code> function is used to retrieve a list of all the images attached to the property. We then confirm a value was returned and process each of those images. Once we have our list of image IDs, we save them to <code>_image_field<\/code> using <code><a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/update_post_meta\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"update_post_meta() (opens in a new tab)\">update_post_meta()<\/a><\/code>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_action( 'pmxi_saved_post', 'update_gallery_ids', 10, 3 );\nfunction update_gallery_ids( $id ) {\n\n    \/\/ Declare our variable for the image IDs.\n    $image_ids = array();\n\n    \/\/ Retrieve all attached images.\n    $media = get_attached_media( 'image', $id );\n\n    \/\/ Ensure there are images to process.\n    if( !empty( $media ) ) {\n\n        \/\/ Process each image.\n        foreach( $media as $item ) {\n\n            \/\/ Add each image ID to our array.\n            $image_ids[] = $item-&gt;ID;\n\n        }\n\n        \/\/ Convert our array of IDs to a comma separated list.\n        $image_ids_str = implode( ',',$image_ids );\n\n        \/\/ Save the IDs to the _image_field custom field.\n        update_post_meta( $id, '_image_field', $image_ids_str );\n        \n    }\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#split-by-index\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"split-by-index\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#split-by-index\" class=\"snippet-title\"><h2><strong>Split String at Delimiter and Return One Value<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use a custom function to divide our string at each comma. Say we have one element in our file that contains all of our Attributes like <code>5, Red<\/code> where the first value is <code>Size<\/code> and the second is <code>Color<\/code>.<\/p>\n\n\n\n<p>We can use our function to return each value as needed like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-08-at-19.34.24-1024x523.png\" alt=\"\" class=\"wp-image-1527\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function return_list_value( $needle, $index, $string ) {\n\n    \/\/ Expect index to start at 1 instead of 0.\n    $index -= 1;\n\n    \/\/ Split string by $needle value.\n    $split = explode($needle, $string);\n\n    \/\/ Return the value at $index.\n    return $split[$index];\n\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#pull-url-from-a-string\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"pull-url-from-a-string\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#pull-url-from-a-string\" class=\"snippet-title\"><h2><strong>Retrieve URL from String<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use a custom function to retrieve a URL from a string.  This can help if your image element has text other than the URL itself.  <\/p>\n\n\n\n<p>For example: <code>&lt;img src='https:\/\/my-image-url.com\/image.jpg' \/&gt;<\/code><\/p>\n\n\n\n<p>The function is called like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-08-at-17.33.55-1024x444.png\" alt=\"\" class=\"wp-image-1522\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function find_url( $string ) {\n    \/\/ Find the URL.\n    preg_match_all('#\\bhttps?:\/\/[^\\s()&lt;>]+(?:\\([\\w\\d]+\\)|([^[:punct:]\\s]|\/))#', $string, $match);\n    \/\/ Return the first found URL.\n    return  $match[0][0];\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#price-rounding\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"price-rounding\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#price-rounding\" class=\"snippet-title\"><h2><strong>Round Imported Prices<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use a custom function to round our prices. The <code>$price<\/code> parameter is required and the others are optional. Any unwanted characters are removed from the price - anything other than 0-9, period, and comma.<\/p>\n\n\n\n<p>It's called like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/Screen-Shot-2020-01-08-at-17.06.42-1024x426.png\" alt=\"\" class=\"wp-image-1520\"\/><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function round_price( $price = null, $multiplier = 1, $nearest = .01, $minus = 0 ) {\n\n    if ( !empty( $price ) ) {\n\n        \/\/ Remove any extra characters from price.\n        $price = preg_replace(\"\/[^0-9,.]\/\", \"\", $price);\n\n        \/\/ Perform calculations and return rounded price.\n        return ( round ( ( $price * $multiplier ) \/ $nearest ) * $nearest ) - $minus; \n\n    }\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#merge-multiple-xml-files\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"merge-multiple-xml-files\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#merge-multiple-xml-files\" class=\"snippet-title\"><h2><strong>Merge Multiple XML Files<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This is a basic example script showing how to merge multiple XML files into 1 file before importing them with WP All Import. This script would be saved in a .php file and placed on your server, then you would point WP All Import to the script URL when setting up the import.<\/p>\n\n\n\n<p>WPAI_Example_Merge_XML_Function parameters:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><tbody><tr><td>Parameter<\/td><td>Description<\/td><\/tr><tr><td>$file1<\/td><td>The full URL\/path\/filename to the main file<\/td><\/tr><tr><td>$file2<\/td><td>The full URL\/path\/filename to the file you want to merge into $file1<\/td><\/tr><tr><td>$root_node<\/td><td>The root node that wraps all of the post nodes<\/td><\/tr><tr><td>$items_node<\/td><td>The repeating post node (i.e. the one you'd choose to import on step 2 of WP All Import).<\/td><\/tr><tr><td>$filename<\/td><td>The file that the merged data will be saved into<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Code:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">&lt;?php\nfunction WPAI_Example_Merge_XML_Function( $file1, $file2, $root_node, $items_node, $filename = 'merged.xml' ) {\n    $main_doc = new DOMDocument();\n    $main_doc->load( $file1 );\n\n    $merge_doc = new DOMDocument();\n    $merge_doc->load( $file2 );\n\n    \/\/ Get root element from file1\n    $root = $main_doc->getElementsByTagName( $root_node )->item(0);\n\n    \/\/ Get post elements from file2 \n    $items = $merge_doc->getElementsByTagName( $items_node );\n\n    for ( $i = 0; $i &lt; $items->length; $i++ ) {\n        $node = $items->item( $i );\n        $import = $main_doc->importNode( $node, true );\n        $root->appendChild( $import );\n    }\n\n    $file = $main_doc->save( $filename );\n}\n\n$final_file_name = 'merged.xml';\nWPAI_Example_Merge_XML_Function( 'd1.xml', 'd2.xml', 'data', 'post', $final_file_name );\nWPAI_Example_Merge_XML_Function( $final_file_name, 'd3.xml', 'data', 'post', $final_file_name );\necho file_get_contents( $final_file_name );\n?><\/code><\/pre><\/div>\n\n\n\n<p>Once you've saved the script in a .php file and uploaded it to your server, you'll point WP All Import to the URL for the script in the \"Download from URL\" field, e.g.: <\/p>\n\n\n\n<p>https:\/\/example.com\/mergexmlscript.php<\/p>\n\n\n\n<p>For reference, these are the XML files that this snippet example works with:<\/p>\n\n\n\n<p>d1.xml<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?>\n&lt;data>\n\t&lt;post>\n\t\t&lt;title>Post 1&lt;\/title>\n\t&lt;\/post>\n&lt;\/data><\/code><\/pre><\/div>\n\n\n\n<p>d2.xml<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?>\n&lt;data>\n\t&lt;post>\n\t\t&lt;title>Post 2&lt;\/title>\n\t&lt;\/post>\n&lt;\/data><\/code><\/pre><\/div>\n\n\n\n<p>d3.xml<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&lt;?xml version=\"1.0\" encoding=\"utf-8\"?>\n&lt;data>\n\t&lt;post>\n\t\t&lt;title>Post 3&lt;\/title>\n\t&lt;\/post>\n&lt;\/data><\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#export-parent-sku-when-variation-sku-is-blank\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"export-parent-sku-when-variation-sku-is-blank\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#export-parent-sku-when-variation-sku-is-blank\" class=\"snippet-title\"><h2><strong>Export parent SKU when variation SKU is blank<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>If your WooCommerce variations are inheriting the Parent SKU, then they will have blank SKUs in your export file. To get around this, you can use the following function on a new instance (\"Add Field\") of the \"ID\" export field:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_get_sku( $id ) {\n\t$prod = wc_get_product( $id );\n\tif ( ! $prod ) return;\n\t\n\tif ( ! empty( $prod-&gt;get_sku() ) ) {\n\t\treturn $prod-&gt;get_sku();\n\t}\n\t\n\tif ( ! empty( $prod-&gt;get_parent_id() ) ) {\n\t\t$parent = wc_get_product( $prod-&gt;get_parent_id() );\n\t\tif ( ! $parent ) return;\n\t\treturn $parent-&gt;get_sku();\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#find-post-by-custom-field-value\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"find-post-by-custom-field-value\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#find-post-by-custom-field-value\" class=\"snippet-title\"><h2><strong>Find post by custom field value<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This is a helper function that can query products, posts, custom post types, users and taxonomy terms by looking up a custom field value. <\/p>\n\n\n\n<p>Example uses are below. Learn how to call PHP functions in imports in our <a href=\"https:\/\/www.wpallimport.com\/documentation\/inline-php\/\" target=\"_blank\" rel=\"noreferrer noopener\">inline PHP doc<\/a>.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">Examples<\/h5>\n\n\n\n<p>Find post with the value from {id[1]} inside the \"_old_post_id\" custom field:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[sf_helper_meta_query_lookup(\"_old_post_id\",{id[1]})]<\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>Find WooCommerce Product with value from {ean[1]} in the \"_custom_ean\" custom field:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[sf_helper_meta_query_lookup(\"_custom_ean\",{ean[1]},\"product\")]<\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>Find user with value from {id[1]} in the \"_old_user_id\" custom field (user meta field):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[sf_helper_meta_query_lookup(\"_old_user_id\",{id[1]},\"user\")]<\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>Find taxonomy term (WooCommerce Product Category in this example) with value from {cat_id[1]} in \"_custom_term_id\" custom field (term meta field):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[sf_helper_meta_query_lookup(\"_custom_term_id\",{cat_id[1]},\"term\",\"product_cat\")]<\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-css-opacity\"\/>\n\n\n\n<p>Code:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function sf_helper_meta_query_lookup( $meta_key = '', $meta_value = '', $object_type = 'post', $taxonomy = '', $return_field = 'ID', $compare = '=', $custom_args = array() ) {\n    if ( empty( $object_type ) || empty( $meta_key ) || empty( $meta_value ) ) return;\n\t$func = 'get_posts';\n\n\tswitch ( $object_type ) {\n\t\tcase 'user':\n\t\t\t$func = 'get_users';\n\t\t\tbreak;\n\t\tcase 'term':\n\t\t\t$func = 'get_terms';\n\t\t\tif ( $return_field == 'ID' ) {\n\t\t\t\t$return_field = 'term_id';\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t$func = 'get_posts';\n\t\t\tbreak;\n\t}\n\t\n\tif ( ! empty( $custom_args ) ) {\n\t\t$objects = $func( $custom_args );\n\t\tif ( ! empty( $objects ) ) {\n\t\t\treturn $objects[0]-&gt;$return_field;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\t\n\t$args = array();\n\t\n\t$meta_query = array( array(\n\t\t'key'     =&gt; $meta_key,\n\t\t'value'   =&gt; $meta_value,\n\t\t'compare' =&gt; $compare\n\t) );\n\t\n\tif ( $func == 'get_terms' ) {\n\t\t$args = array(\n\t\t\t'taxonomy'   =&gt; $taxonomy,\n\t\t\t'hide_empty' =&gt; false,\n\t\t\t'meta_query' =&gt; $meta_query\n\t\t);\n\t} elseif ( $func == 'get_users' ) {\n\t\t$args = array( \n\t\t\t'meta_query' =&gt; $meta_query\n\t\t);\n\t} else {\n\t\t$args = array(\n\t\t\t'post_type'  =&gt; $object_type,\n\t\t\t'meta_query' =&gt; $meta_query\n\t\t);\n\t}\n\t\t\t\n    if ( $objects = $func( $args ) ) {\n        return $objects[0]-&gt;$return_field;\n    } else {\n\t\treturn false;\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#keep-old-ids-when-migrating-products\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"keep-old-ids-when-migrating-products\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#keep-old-ids-when-migrating-products\" class=\"snippet-title\"><h2><strong>Keep old IDs when migrating products or posts<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet attempts to keep the old post\/product ID when you migrate posts\/products from one site to another. It should be saved on the import site via <strong>All Import<\/strong> \u203a <strong>Settings<\/strong> \u203a <strong>Function Editor<\/strong>.<\/p>\n\n\n\n<p>Important note: if a post of any type exists on the new site with an ID that you're attempting to use from the old site, then this snippet won't work and a new ID will be generated for the imported post. <\/p>\n\n\n\n<p>This workaround does not work for WooCommerce orders.<\/p>\n\n\n\n<p>For users and customers see <a href=\"https:\/\/www.wpallimport.com\/documentation\/developers\/code-snippets\/#keep-old-ids-when-migrating-users-or-customers\">Keep old IDs when migrating users or customers<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_pmxi_article_data( $articleData, $import, $post_to_update, $current_xml_node ) {\n    \/\/ Turn the XML node into an array.\n    $xml_data = json_decode( json_encode( (array) $current_xml_node ), 1 );\n\n    \/\/ Change 'id' if your ID exists in an element not named {id[1]}.\n    $articleData['import_id'] = $xml_data['id'];\n\n    \/\/ Return article data.\n    return $articleData;\n}\nadd_filter('pmxi_article_data', 'my_pmxi_article_data', 10, 4);<\/code><\/pre><\/div>\n\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#keep-old-ids-when-migrating-users-or-customers\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"keep-old-ids-when-migrating-users-or-customers\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#keep-old-ids-when-migrating-users-or-customers\" class=\"snippet-title\"><h2><strong>Keep Old IDs When Migrating Users or Customers<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet attempts to keep the old user\/customer ID when you migrate users\/customers from one site to another. It should be saved on the import site via All Import \u203a Settings \u203a Function Editor.<\/p>\n\n\n\n<p>Important note: if a user\/customer exists on the new site with an ID that you're attempting to use from the old site, then this snippet won't work and a new ID will be generated for the imported user\/customer. Also, an ID will be auto-assigned when the user or customer is created. This snippet then tries to update that ID to the one specified.<\/p>\n\n\n\n<p>For posts (or products) see <a href=\"https:\/\/www.wpallimport.com\/documentation\/developers\/code-snippets\/#keep-old-ids-when-migrating-products\">Keep old IDs when migrating products or posts<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_set_user_id( $post_id, $xml_node, $is_update ) {\n\n\tglobal $wpdb;\n\n\t\/\/ Retrieve the import ID.\n\t$import_id = wp_all_import_get_import_id();\n\n\t\/\/ Only run for import 1 and only run when the user is first created.\n\tif ( $import_id == '1' &amp;&amp; !$is_update) {\n\n\t\t\/\/ Convert SimpleXml object to array for easier use.\n\t\t$record = json_decode( json_encode( ( array ) $xml_node ), 1 );\n\n\t\t\/\/ ID to set for user, change 'userid' to your real file element name.\n\t\t$requested_id = $record['userid'];\n\n\t\t\/\/ Check if the requested ID is already used.\n\t\t$id_exists = $wpdb-&gt;get_var($wpdb-&gt;prepare('SELECT user_login FROM '.$wpdb-&gt;users.' WHERE ID = '.$requested_id));\n\n\t\t\/\/ If the requested ID is available...\n\t\tif( $id_exists === null ){\n\n\t\t\t\/\/ ...assign the user ID as desired...\n\t\t\t$wpdb-&gt;update($wpdb-&gt;users, ['ID'=&gt; $requested_id], ['ID' =&gt; $post_id]);\n\n\t\t\t\/\/ ...update the user ID for the associated meta, so the association with the user isn't lost...\n\t\t\t$wpdb-&gt;update($wpdb-&gt;usermeta, ['user_id'=&gt; $requested_id], ['user_id' =&gt; $post_id]);\n\n\t\t\t\/\/ ...and update the ID in the pmxi_posts table, so the import can still manage this user.\n\t\t\t$wpdb-&gt;update($wpdb-&gt;prefix . 'pmxi_posts', ['post_id'=&gt; $requested_id], ['post_id' =&gt; $post_id, 'import_id' =&gt; $import_id]);\n\t\t}\n\n\t}\n\n}\nadd_action( 'pmxi_saved_post', 'my_set_user_id', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#keep-old-ids-when-migrating-categories-and-other-taxonomy-terms\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"keep-old-ids-when-migrating-categories-and-other-taxonomy-terms\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#keep-old-ids-when-migrating-categories-and-other-taxonomy-terms\" class=\"snippet-title\"><h2><strong>Keep old IDs when migrating categories and other taxonomy terms<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This code tries to keep the old term ID when you migrate taxonomy terms from one site to another. It can be saved on the import site via All Import \u203a Settings \u203a Function Editor.<\/p>\n\n\n\n<p>Important note: if a term in any taxonomy exists on the new site with an ID that you're attempting to use from the old site, then this code won't work and a new ID will be generated for the imported term.<\/p>\n\n\n\n<p>For products or posts see <a href=\"https:\/\/www.wpallimport.com\/snippets\/keep-old-ids-when-migrating-products-or-posts\/\">Keep old IDs when migrating products or posts<\/a>, and for users or customers see&nbsp;<a href=\"https:\/\/www.wpallimport.com\/documentation\/developers\/code-snippets\/#keep-old-ids-when-migrating-users-or-customers\">Keep old IDs when migrating users or customers<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_set_term_id( $post_id, $xml_node, $is_update ) {\n\n\tglobal $wpdb;\n\n\t\/\/ Retrieve the import ID.\n\t$import_id = wp_all_import_get_import_id();\n\n\t\/\/ Only run for import 1 and only run when the term is first created.\n\tif ( $import_id == '1' &amp;&amp; !$is_update) {\n\n\t\t\/\/ Convert SimpleXml object to array for easier use.\n\t\t$record = json_decode( json_encode( ( array ) $xml_node ), 1 );\n\n\t\t\/\/ ID to set for term, change 'termid' to your real file element name.\n\t\t$requested_id = $record['termid'];\n\n\t\t\/\/ Check if the requested term_id is already used.\n\t\t$id_exists = $wpdb->get_var($wpdb->prepare('SELECT name FROM '.$wpdb->terms.' WHERE term_id = '.$requested_id));\n\n\t\t\/\/ If the requested term_id is available...\n\t\tif( $id_exists === null ){\n\n\t\t\t\/\/ ...assign the term ID as desired...\n\t\t\t$wpdb->update($wpdb->terms, ['term_id'=> $requested_id], ['term_id' => $post_id]);\n\n\t\t\t\/\/ ...update the term ID for the associated meta, so the association with the term isn't lost...\n\t\t\t$wpdb->update($wpdb->termmeta, ['term_id'=> $requested_id], ['term_id' => $post_id]);\n\t\t\t\n\t\t\t\/\/ ...update the term ID for the associated taxonomy, so the association isn't lost...\n\t\t\t$wpdb->update($wpdb->term_taxonomy, ['term_id'=> $requested_id], ['term_id' => $post_id]);\n\n\t\t\t\/\/ ...and update the ID in the pmxi_posts table, so the import can still manage this term.\n\t\t\t$wpdb->update($wpdb->prefix . 'pmxi_posts', ['post_id'=> $requested_id], ['post_id' => $post_id, 'import_id' => $import_id]);\n\t\t}\n\n\t}\n\n}\nadd_action( 'pmxi_saved_post', 'my_set_term_id', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#prepend-url-to-multiple-images-in-a-single-element\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"prepend-url-to-multiple-images-in-a-single-element\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#prepend-url-to-multiple-images-in-a-single-element\" class=\"snippet-title\"><h2><strong>Prepend URL to multiple images in a single element<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>If you have an import element with multiple image names, like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;images&gt;img-name-1.jpg|img-name-2.jpg|img-name-3.jpg&lt;\/images&gt;<\/code><\/pre>\n\n\n\n<p>And, you need to add a URL before each image name, like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><meta charset=\"utf-8\">https:\/\/example.com\/images\/img-name-1.jpg|<meta charset=\"utf-8\">https:\/\/example.com\/images\/img-name-2.jpg|<meta charset=\"utf-8\">https:\/\/example.com\/images\/img-name-3.jpg<\/code><\/pre>\n\n\n\n<p>You can use this function:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_output_images( $prepend_url, $separator = ',', $image_urls ) {\n\t\/\/ Turn the image URLs into an array.\n\t$image_urls = explode( $separator, $image_urls );\n\t\n\t\/\/ Remove empty entries.\n\t$image_urls = array_filter( $image_urls );\n\t\n\t\/\/ Prepend the URL to every image.\n\tforeach ( $image_urls as $key => $url ) {\n\t\t$image_urls[ $key ] = $prepend_url . trim( $url );\n\t}\n\t\n\t\/\/ Return a string of image URLs with the proper separator.\n\treturn implode( $separator, $image_urls );\n}<\/code><\/pre><\/div>\n\n\n\n<p>Example usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>[my_output_images(\"https:\/\/example.com\/images\/\",\"|\",{images[1]})]<\/code><\/pre>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#keep-old-ids-when-migrating-comments\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"keep-old-ids-when-migrating-comments\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#keep-old-ids-when-migrating-comments\" class=\"snippet-title\"><h2><strong>Keep Old IDs When Migrating Comments<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet attempts to keep the old comment IDs when you migrate comments from one site to another. It should be saved on the import site via All Import \u203a Settings \u203a Function Editor.<\/p>\n\n\n\n<p>Important note: if a comment exists on the new site with an ID that you're attempting to use from the old site, then this snippet won't work and a new ID will be generated for the imported comment. Also, an ID will be auto-assigned when the comment is created; this snippet then tries to update that ID to the one specified.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_set_comment_id( $post_id, $xml_node, $is_update ) {\n\n\tglobal $wpdb;\n\n\t\/\/ Retrieve the import ID.\n\t$import_id = wp_all_import_get_import_id();\n\n\t\/\/ Only run for import 1 and only run when the comment is first created.\n\tif ( $import_id == '1' &amp;&amp; !$is_update) {\n\n\t\t\/\/ Convert SimpleXml object to array for easier use.\n\t\t$record = json_decode( json_encode( ( array ) $xml_node ), 1 );\n\n\t\t\/\/ ID to set for comment, change 'commentid' to your real file element name.\n\t\t$requested_id = $record['commentid'];\n\n\t\t\/\/ Check if the requested ID is already used.\n\t\t$id_exists = $wpdb->get_var($wpdb->prepare('SELECT comment_ID FROM '.$wpdb->comments.' WHERE ID = '.$requested_id));\n\n\t\t\/\/ If the requested ID is available...\n\t\tif( $id_exists === null ){\n\n\t\t\t\/\/ ...assign the comment ID as desired...\n\t\t\t$wpdb->update($wpdb->comments, ['comment_ID'=> $requested_id], ['comment_ID' => $post_id]);\n\n\t\t\t\/\/ ...update the comment ID for the associated meta, so the association with the comment isn't lost...\n\t\t\t$wpdb->update($wpdb->commentmeta, ['comment_id'=> $requested_id], ['comment_id' => $post_id]);\n\n\t\t\t\/\/ ...and update the ID in the pmxi_posts table, so the import can still manage this comment.\n\t\t\t$wpdb->update($wpdb->prefix . 'pmxi_posts', ['post_id'=> $requested_id], ['post_id' => $post_id, 'import_id' => $import_id]);\n\t\t}\n\n\t}\n\n}\nadd_action( 'pmxi_saved_post', 'my_set_comment_id', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#save-imported-images-to-a-folder-based-on-the-post-date\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"save-imported-images-to-a-folder-based-on-the-post-date\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#save-imported-images-to-a-folder-based-on-the-post-date\" class=\"snippet-title\"><h2><strong>Save Imported Images To A Folder Based On The Post Date<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the&nbsp;<code><a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_import_images_uploads_dir\">wp_all_import_images_uploads_dir<\/a><\/code>&nbsp;filter to save our images to folders based on imported post dates (in YYYY\/MM format).<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpai_set_upload_folder_by_post_date($uploads, $articleData, $current_xml_node, $import_id) {\n\tif ( ! empty($articleData['post_date'])) {\n\t\t$uploads['path'] = $uploads['basedir'] . '\/' . date(\"Y\/m\", strtotime($articleData['post_date']));\n\t\t$uploads['url'] = $uploads['baseurl'] . '\/' . date(\"Y\/m\", strtotime($articleData['post_date']));\n\n\t\tif (!file_exists($uploads['path'])) {\n\t\t\tmkdir($uploads['path'], 0755, true);\n\t\t}\n\t}\n\treturn $uploads;\n}\n\nadd_filter('wp_all_import_images_uploads_dir', 'wpai_set_upload_folder_by_post_date', 10, 4);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#send-export-file-via-email\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"send-export-file-via-email\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#send-export-file-via-email\" class=\"snippet-title\"><h2><strong>Send Export File via Email<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here we use the <code><a aria-label=\"pmxe_after_export (opens in a new tab)\" href=\"\/documentation\/advanced\/action-reference\/#pmxe_after_export\" target=\"_blank\" rel=\"noreferrer noopener\">pmxe_after_export<\/a><\/code> action to send our export file using <code><a aria-label=\"wp_mail() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_mail\/\" target=\"_blank\" rel=\"noreferrer noopener\">wp_mail()<\/a><\/code>. We also make use of <code><a aria-label=\"get_attached_file() (opens in a new tab)\" href=\"https:\/\/developer.wordpress.org\/reference\/functions\/get_attached_file\/\" target=\"_blank\" rel=\"noreferrer noopener\">get_attached_file()<\/a><\/code> to retrieve the export file when WP All Export's Secure Mode is off.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function move_export_file_email($export_id, $exportObj)\n{\n\t\/\/ Check whether \"Secure Mode\" is enabled in All Export &gt; Settings.\n\t$is_secure_export = PMXE_Plugin::getInstance()-&gt;getOption('secure');\n\tif (!$is_secure_export) {\n\t\t\/\/ Get filepath when 'Secure Mode' is off.\n\t\t$filepath = get_attached_file($exportObj-&gt;attch_id);\n\t} else {\n\t\t\/\/ Get filepath with 'Secure Mode' on.\n\t\t$filepath = wp_all_export_get_absolute_path($exportObj-&gt;options['filepath']);\n\t}\n\t\/\/Send email with the attachment\n\twp_mail(\n            'example@example.com', \/\/ email to send to\n            'New Export ID ' . $export_id,\n            'Attached is your latest export.',\n            array(\n                'From: Soflyy &lt;support@wpallimport.com&gt;',\n                \/\/ 'Bcc: Webmaster &lt;webmaster@example.com&gt;',\n            ),\n            array ( $filepath ),\n        );\n}\nadd_action('pmxe_after_export', 'move_export_file_email', 10, 2);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#generate-dynamic-import-url\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"generate-dynamic-import-url\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#generate-dynamic-import-url\" class=\"snippet-title\"><h2><strong>Generate Dynamic Import URL<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Generating a dynamic import URL requires the use of a custom PHP function in&nbsp;<strong>Download a file \u203a From URL<\/strong>&nbsp;in Step 1 of the import process. For example, if the filename is based on a date, you would need to write your function like this:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function get_dynamic_import_url() {\n        return \"http:\/\/www.site.com\/\". myfunction();\n}<\/code><\/pre><\/div>\n\n\n\n<p>Where \"myfunction\" is a separate function you need to write to get the correct date for the feed.<\/p>\n\n\n\n<p>Once you've written the necessary code, you would need to add the code to:<\/p>\n\n\n\n<p>A) Your theme's functions.php file.<br>B) A plugin like&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\">Code Snippets<\/a>.<\/p>\n\n\n\n<p>And call it in the field like this:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[get_dynamic_import_url()]<\/code><\/pre><\/div>\n\n\n\n<p>Please see the screenshot below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/06\/Generate-Dynamic-Import-URL.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"966\" height=\"560\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/06\/Generate-Dynamic-Import-URL.png\" alt=\"Generate Dynamic Import URL\" class=\"wp-image-5811254\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/06\/Generate-Dynamic-Import-URL.png 966w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/06\/Generate-Dynamic-Import-URL-300x174.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/06\/Generate-Dynamic-Import-URL-768x445.png 768w\" sizes=\"(max-width: 966px) 100vw, 966px\" \/><\/a><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#export-toolset-relationship-fields\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"export-toolset-relationship-fields\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#export-toolset-relationship-fields\" class=\"snippet-title\"><h2><strong>Export Toolset Relationship Fields<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Toolset Types uses custom database tables. To export relationship fields, you can apply the example function below on a new instance of the \"ID\" field in the export. This example function returns related titles in a relationship with the slug 'post-page'. See:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Export-Toolset-Relationship-Field.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"565\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Export-Toolset-Relationship-Field-1024x565.png\" alt=\"Export Toolset Relationship Field\" class=\"wp-image-5817133\" style=\"width:840px;height:463px\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Export-Toolset-Relationship-Field-1024x565.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Export-Toolset-Relationship-Field-300x166.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Export-Toolset-Relationship-Field-768x424.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Export-Toolset-Relationship-Field.png 1422w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Here's the code:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_toolset_get_related_posts( $id ) {\n\t$related = toolset_get_related_posts( $id, 'post-page', array( 'query_by_role' =&gt; 'parent' ) );\n\tif ( ! empty( $related ) &amp;&amp; is_array( $related ) ) {\n\t\tarray_walk( $related, function( &amp;$item ) {\n\t\t\t$item = get_post_field( 'post_title', $item );\n\t\t} );\n\t\treturn implode( '|', $related );\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#how-to-increase-stock-instead-of-replacing-it\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"how-to-increase-stock-instead-of-replacing-it\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#how-to-increase-stock-instead-of-replacing-it\" class=\"snippet-title\"><h2><strong>How to Increase Stock Instead of Replacing It<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>1. Create a new import that uses Manual Record Matching to update the products:&nbsp;<a href=\"http:\/\/www.wpallimport.com\/documentation\/recurring\/manual-record-matching\/\">https:\/\/www.wpallimport.com\/documentation\/manual-record-matching\/<\/a>.<\/p>\n\n\n\n<p>2- In Step 3 of the import process, import the stock value into a custom field named something like \"_my_new_stock\":<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example.jpg\" data-rel=\"lightbox-image-3\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"273\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example-1024x273.jpg\" alt=\"Increase Stock Custom Field Example\" class=\"wp-image-5817326\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example-1024x273.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example-300x80.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example-768x205.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example-1536x409.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Custom-Field-Example.jpg 1876w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>3. Save the following code inside the <strong>Function Editor<\/strong> (All Import \u203a Settings):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_add_stock( $product_id, $xml, $update ) {\n\t$new_stock = get_post_meta( $product_id, '_my_new_stock', true );\n\twc_update_product_stock( $product_id, $new_stock, 'increase' );\n}\n\nadd_action( 'pmxi_saved_post', 'soflyy_add_stock', 10, 3 );<\/code><\/pre><\/div>\n\n\n\n<p>4. In Step 4 of the import process, use the <strong>Choose which data to update<\/strong> option to make sure you're only updating the \"_my_new_stock\" field:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update.jpg\" data-rel=\"lightbox-image-4\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-1024x1024.jpg\" alt=\"Increase Stock Define Custom Field to Update\" class=\"wp-image-5817327\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-1024x1024.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-300x300.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-150x150.jpg 150w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-768x767.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-1536x1534.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-128x128.jpg 128w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update-256x256.jpg 256w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Increase-Stock-Define-Custom-Field-to-Update.jpg 1868w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Some things to keep in mind with this workaround are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Re-running the import will increment the stock again.<\/li>\n\n\n\n<li>If the import terminates, ensure it starts back up at the record on which it terminated.<\/li>\n<\/ul>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#query-orders-by-old-id\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"query-orders-by-old-id\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#query-orders-by-old-id\" class=\"snippet-title\"><h2><strong>Query Orders by Old ID<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p><strong>Workaround 1: Plugin Solution<\/strong><\/p>\n\n\n\n<p>1. Install Booster for WooCommerce:&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/woocommerce-jetpack\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/wordpress.org\/plugins\/woocommerce-jetpack\/<\/a>.<\/p>\n\n\n\n<p>2. Navigate to <strong>WooCommerce \u203a Settings \u203a Booster<\/strong>, then click on <strong>SHIPPING &amp; ORDERS<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Shipping-and-Orders-Plugin-Example.png\" data-rel=\"lightbox-image-5\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"156\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Shipping-and-Orders-Plugin-Example-1024x156.png\" alt=\"Shipping and Orders Plugin Example\" class=\"wp-image-5817997\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Shipping-and-Orders-Plugin-Example-1024x156.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Shipping-and-Orders-Plugin-Example-300x46.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Shipping-and-Orders-Plugin-Example-768x117.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Shipping-and-Orders-Plugin-Example.png 1290w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Click <strong>Settings<\/strong> for <strong>Order Numbers<\/strong>. Enable the <strong>Enable Module<\/strong> checkbox, then click <strong>Save changes<\/strong> at the bottom.<\/p>\n\n\n\n<p>3. Now, when importing your orders, import the old order ID into the <strong>_wcj_order_number<\/strong> custom field:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number.jpg\" data-rel=\"lightbox-image-6\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"315\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number-1024x315.jpg\" alt=\"Custom Field Order ID _wcj_order_number\" class=\"wp-image-5817999\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number-1024x315.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number-300x92.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number-768x237.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number-1536x473.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Order-ID-_wcj_order_number.jpg 1610w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Workaround 2: Custom Solution<\/strong><\/p>\n\n\n\n<p>When migrating orders from one site to another using WP All Export &amp; WP All Import, new order IDs will be generated by WordPress on the new site. If you need to retain the old ID for some reason, you can instead query the orders by their old IDs with this workaround:<\/p>\n\n\n\n<p>1. In your import template, import the {orderid[1]} element inside a custom field called <strong>_old_order_id<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example.jpg\" data-rel=\"lightbox-image-7\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"320\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example-1024x320.jpg\" alt=\"Custom Field Old Order ID Example\" class=\"wp-image-5818000\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example-1024x320.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example-300x94.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example-768x240.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example-1536x480.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Custom-Field-Old-Order-ID-Example.jpg 1614w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>2. Add the following code to your site via a plugin like&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">Code Snippets<\/a>&nbsp;or in your child themes functions.php file:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter( 'woocommerce_shop_order_search_fields', 'soflyyexample_shop_order_search_by_old_order_id', 10, 1 );\n\nfunction soflyyexample_shop_order_search_by_old_order_id( $search_fields ) {\n\t$search_fields[] = '_old_order_id';\n\treturn $search_fields;\n}<\/code><\/pre><\/div>\n\n\n\n<p>Now, when you search via the <strong>WooCommerce \u203a Orders<\/strong> page, it will also look inside the <strong>_old_order_id<\/strong> custom field. Optionally, you can add the following code to your site in order to display the old order ID on the Orders admin page:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter( 'manage_woocommerce_page_wc-orders_columns', 'soflyy_example_add_old_order_id_column', 20 );\nadd_action( 'manage_woocommerce_page_wc-orders_custom_column', 'soflyyexample_add_old_order_id_column_content' );\n\nfunction soflyy_example_add_old_order_id_column( $columns ) {\n\n    $all_columns = array();\n\n    foreach ( $columns as $name => $info ) {\n        $all_columns[ $name ] = $info;\n        if ( $name === 'order_status' ) {\n            $all_columns['old_order_id'] = __( 'Old Order ID' );\n        }\n    }\n    return $all_columns;\n}\n\nfunction soflyyexample_add_old_order_id_column_content( $column ) {\n    global $post;\n\n    if ( $column === 'old_order_id' ) {\n        $old_order_id = get_post_meta( $post->ID, '_old_order_id', true );\n        echo $old_order_id;\n    }\n}<\/code><\/pre><\/div>\n\n\n\n<p>Result:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Old-Order-ID-Example-Column.png\" data-rel=\"lightbox-image-8\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"853\" height=\"318\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Old-Order-ID-Example-Column.png\" alt=\"Old Order ID Example Column\" class=\"wp-image-5817998\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Old-Order-ID-Example-Column.png 853w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Old-Order-ID-Example-Column-300x112.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/08\/Old-Order-ID-Example-Column-768x286.png 768w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><\/a><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#use-xpath-query-based-on-cyrillic-attribute-value\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"use-xpath-query-based-on-cyrillic-attribute-value\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#use-xpath-query-based-on-cyrillic-attribute-value\" class=\"snippet-title\"><h2><strong>Use XPath Query Based on Cyrillic Attribute Value<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>XPath doesn't allow you to make queries with Cyrillic symbols unless you disable XML pre-processing by adding this code in your child themes functions.php file (or in a plugin like Code Snippets:&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/wordpress.org\/plugins\/code-snippets\/<\/a>):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function wpai_is_xml_preprocess_enabled( $is_enabled ) {\n\treturn false;\n}\nadd_filter( 'is_xml_preprocess_enabled', 'wpai_is_xml_preprocess_enabled', 10, 1 );<\/code><\/pre><\/div>\n\n\n\n<p>Once that code is in place, upload your file to an import, and queries like this will be possible:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xpath\"><pre class=\"line-numbers\"><code class=\"language-xpath\">{param[@name=\"\u0422\u0438\u043f \u0441\u043d\u0430\u0440\u044f\u0436\u0435\u043d\u0438\u044f\"]}\n{param[@name=\"\u0420\u0443\u043b\u0435\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430\"]}\n{param[@name=\"\u041f\u0435\u0434\u0430\u043b\u0438\"]}<\/code><\/pre><\/div>\n\n\n\n<p>If you need to keep pre-processing enabled, there are other solutions:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Scenario One<\/h3>\n\n\n\n<p>If the values that you're importing do not contain commas, you can use a PHP function to query them.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">File Structure<\/h4>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&#x3C;?xml version=\"1.0\" encoding=\"utf-8\"?&#x3E;\n&#x3C;products&#x3E;\n\t&#x3C;product&#x3E;\n\t\t&#x3C;title&#x3E;Product A&#x3C;\/title&#x3E;\n\t\t&#x3C;sku&#x3E;PRODA&#x3C;\/sku&#x3E;\n\t\t&#x3C;price&#x3E;10&#x3C;\/price&#x3E;\n\t\t&#x3C;param name=\"\u0420\u0443\u043b\u0435\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430\"&#x3E;Example value here&#x3C;\/param&#x3E;\n\t\t&#x3C;param name=\"\u041f\u0435\u0434\u0430\u043b\u0438\"&#x3E;Another value here&#x3C;\/param&#x3E;\n\t&#x3C;\/product&#x3E;\n&#x3C;\/products&#x3E;<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Function Code<\/h4>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function map_params( $names, $values, $key ) {\n\tif ( empty( $key ) ) return ''; \n\n\t$result = '';\n\t$names_arr = explode( \",\", $names );\n\t$values_arr = explode( \",\", $values );\n\n\tif ( ! empty( $names_arr ) ) {\n\t\tforeach ( $names_arr as $i =&gt; $name ) { \n\t\t\tif ( trim( pmxi_convert_encoding( $name, \"UTF-8\" ) ) == $key ) {\n\t\t\t\t$result = isset( $values_arr[ $i ] ) ? trim( $values_arr[ $i ] ) : '';\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn $result;\n}<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Usage example<\/h4>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xpath\"><pre class=\"line-numbers\"><code class=\"language-xpath\">[map_params({param\/@name},{param},\"\u0420\u0443\u043b\u0435\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430\")]<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Scenario Two<\/h3>\n\n\n\n<p>If the values contain commas, you'll need to use the wpallimport_xml_row hook to query them.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">File Structure<\/h4>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xml\"><pre class=\"line-numbers\"><code class=\"language-xml\">&#x3C;?xml version=\"1.0\" encoding=\"utf-8\"?&#x3E;\n&#x3C;products&#x3E;\n\t&#x3C;product&#x3E;\n\t\t&#x3C;title&#x3E;Product A&#x3C;\/title&#x3E;\n\t\t&#x3C;sku&#x3E;PRODA&#x3C;\/sku&#x3E;\n\t\t&#x3C;price&#x3E;10&#x3C;\/price&#x3E;\n\t\t&#x3C;param name=\"\u0420\u0443\u043b\u0435\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430\"&#x3E;Example, values, here&#x3C;\/param&#x3E;\n\t\t&#x3C;param name=\"\u041f\u0435\u0434\u0430\u043b\u0438\"&#x3E;More, values, here&#x3C;\/param&#x3E;\n\t&#x3C;\/product&#x3E;\n&#x3C;\/products&#x3E;<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Code Example<\/h4>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function add_param_nodes( $node ) {\n    $results = $node-&gt;xpath( 'param' );\n\t  $att = 'name';\n    if ( !empty( $results ) ) {\n        foreach( $results as $result ) {\n\t\t\t$atts = (string) $result-&gt;attributes();\n\t\t\t$atts = trim( pmxi_convert_encoding( $atts, \"UTF-8\" ) );\n\t\t\tif ( ! empty( $atts ) &amp;&amp; $atts == '\u0412\u043e\u0437\u0440\u0430\u0441\u0442' ) {\n\t\t\t\t$node-&gt;addChild( '\u0412\u043e\u0437\u0440\u0430\u0441\u0442', $result-&gt;__toString() );\n\t\t\t} elseif ( ! empty( $atts ) &amp;&amp; $atts == '\u041f\u043e\u043b' ) {\n\t\t\t\t$node-&gt;addChild( '\u041f\u043e\u043b', $result-&gt;__toString() );\n\t\t\t} elseif ( ! empty( $atts ) &amp;&amp; $atts == '\u0420\u0430\u0437\u043c\u0435\u0440' ) {\n\t\t\t\t$node-&gt;addChild( '\u0420\u0430\u0437\u043c\u0435\u0440', $result-&gt;__toString() );\n\t\t\t}\n\t\t}\n    }\n    return $node;\n}\nadd_filter( 'wpallimport_xml_row', 'add_param_nodes', 10, 1 );<\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Usage Example<\/h4>\n\n\n\n<p>This would add 2 new XPath elements that you can use in your import template:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xpath\"><pre class=\"line-numbers\"><code class=\"language-xpath\">{\u0420\u0443\u043b\u0435\u0432\u0430\u044f\u043a\u043e\u043b\u043e\u043d\u043a\u0430[1]}\n{\u041f\u0435\u0434\u0430\u043b\u0438[1]}<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Alternative Workaround<\/h3>\n\n\n\n<p>You could convert the attribute name to HTML entities and query it that way. For example, to query \"\u0420\u0443\u043b\u0435\u0432\u0430\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0430\", you'd use the following XPath:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xpath\"><pre class=\"line-numbers\"><code class=\"language-xpath\">{param[@name=\"&#x420;&#x443;&#x43B;&#x435;&#x432;&#x430;&#x44F; &#x43A;&#x43E;&#x43B;&#x43E;&#x43D;&#x43A;&#x430;\"]}<\/code><\/pre><\/div>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/trey8611\/7b6e79e6610f9d2b06257fb570f05e03#file-structure\"><\/a><\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#export-data-from-custom-database-tables\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"export-data-from-custom-database-tables\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#export-data-from-custom-database-tables\" class=\"snippet-title\"><h2><strong>Export Data From Custom Database Tables<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Sometimes, you might need to export extra data from a custom database table. This is possible by using a <a href=\"https:\/\/www.wpallimport.com\/documentation\/custom-wordpress-export-php\/\" target=\"_blank\" rel=\"noreferrer noopener\">custom PHP function<\/a> in the export along with the <a href=\"https:\/\/developer.wordpress.org\/reference\/classes\/wpdb\/\" target=\"_blank\" rel=\"noreferrer noopener\">wpdb {} class<\/a>.<\/p>\n\n\n\n<p>For example, let\u2019s say that we are exporting Users from a BuddyPress installation, and we need to get the value of the <strong>Name<\/strong> field from the BuddyPress <strong>Extended Profile<\/strong> section:&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Name-Field-Example.png\" data-rel=\"lightbox-image-9\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"474\" height=\"262\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Name-Field-Example.png\" alt=\"BuddyPress Name Field Example\" class=\"wp-image-5819168\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Name-Field-Example.png 474w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Name-Field-Example-300x166.png 300w\" sizes=\"(max-width: 474px) 100vw, 474px\" \/><\/a><\/figure>\n\n\n\n<p>This information is stored inside the 'bp_xprofile_data' table:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Example-Field-in-Database.png\" data-rel=\"lightbox-image-10\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"478\" height=\"117\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Example-Field-in-Database.png\" alt=\"BuddyPress Example Field in Database\" class=\"wp-image-5819169\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Example-Field-in-Database.png 478w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/BuddyPress-Example-Field-in-Database-300x73.png 300w\" sizes=\"(max-width: 478px) 100vw, 478px\" \/><\/a><\/figure>\n\n\n\n<p>To export this, we'll want to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click <strong>Add Field<\/strong> in our export, keep <strong>ID<\/strong> in the top drop-down.<\/li>\n\n\n\n<li>Name the field, for example, 'BuddyPress Name'.<\/li>\n\n\n\n<li>Click<strong> Export the value returned by a PHP function<\/strong>.<\/li>\n\n\n\n<li>Type in our function name, add the code to the <strong>Function Editor<\/strong>, and click <strong>Done<\/strong>.<\/li>\n<\/ul>\n\n\n\n<p>Example: <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Export-Data-from-Custom-Database.gif\" data-rel=\"lightbox-image-11\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"2176\" height=\"1718\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Export-Data-from-Custom-Database.gif\" alt=\"Export Data from Custom Database\" class=\"wp-image-5819182\"\/><\/a><\/figure>\n\n\n\n<p>Example code:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_get_bp_name( $user_id ) {\n\tglobal $wpdb;\n\t$table = $wpdb-&gt;prefix . 'bp_xprofile_data';\n\t\n\t$results = $wpdb-&gt;get_row( $wpdb-&gt;prepare( \"SELECT `value` FROM `\" . $table . \"` WHERE `user_id` = '%d' AND `field_id` = '1' LIMIT 1\", $user_id ) );\n\t\n\tif ( !empty( $results-&gt;value ) ) {\n\t\treturn $results-&gt;value;\n\t}\n\treturn null;\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-users-with-the-same-email\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-users-with-the-same-email\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-users-with-the-same-email\" class=\"snippet-title\"><h2><strong>Import Users With The Same Email<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>WordPress doesn't allow multiple users to share the same e-mail address, but there are certain plugins that change that behavior. These example snippets are supposed to be used along with those plugins. Here's a quick example of importing users with the same email address:<\/p>\n\n\n\n<p>1. In the <strong>Email (required)<\/strong> field, use this function:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[my_random_email()]<\/code><\/pre><\/div>\n\n\n\n<p>The code that goes in the <strong>Function Editor<\/strong> is:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_random_email() {\n\treturn substr( md5( rand( 1,99999 ) ), 0, 3 ) . substr( md5( rand( 1, 99999 ) ), 0, 7 ) . '@example.com';\n}<\/code><\/pre><\/div>\n\n\n\n<p>2. In the <strong>Custom Fields<\/strong> section, import the actual email import element into a custom field called '_my_temp_email', e.g.:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp.jpg\" data-rel=\"lightbox-image-12\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"268\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp-1024x268.jpg\" alt=\"User Same Email Custom Fields Temp\" class=\"wp-image-5819496\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp-1024x268.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp-300x79.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp-768x201.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp-1536x403.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/User-Same-Email-Custom-Fields-Temp.jpg 1854w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>3. In the <strong>Function Editor<\/strong>, also save the following code to convert the random email to the actual email when the user is saved:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_action( 'pmxi_saved_post', 'my_set_email', 10, 3 );\n\nfunction my_set_email( $id, $xml, $update ) {\n\t$import_id        = wp_all_import_get_import_id();\n\t$check_type       = 'import_users';\t\n\t$import           = new PMXI_Import_Record();\n\t$import-&gt;getById( $import_id );\t\n\t$import_post_type = $import-&gt;options['custom_type'];\n\t\n\tif ( $import_post_type == $check_type ) {\n\t\t$email = get_user_meta( $id, '_my_temp_email', true );\n\t\tif ( ! empty( $email ) ) {\n\t\t\t$args = array(\n\t\t\t\t'ID'         =&gt; $id,\n\t\t\t\t'user_email' =&gt; $email\n\t\t\t);\n\t\t\twp_update_user( $args );\n\t\t}\n\t}\n\tdelete_user_meta( $id, '_my_temp_email' );\n}<\/code><\/pre><\/div>\n\n\n\n<p>That\u2019s it. Keep in mind that this code runs for all user imports, so you might consider wrapping it in an&nbsp;<a href=\"http:\/\/php.net\/manual\/en\/control-structures.if.php\" target=\"_blank\" rel=\"noreferrer noopener\">if conditional<\/a>&nbsp;based on the import ID (which can be obtained using the wp_all_import_get_import_id() function, as done in the code example).<\/p>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-grouped-products\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-grouped-products\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-grouped-products\" class=\"snippet-title\"><h2><strong>Import Grouped Products<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>To import Grouped Products and their grouped Simple Products in a single import, you will require some specific data in your import. This is a small guide to point you in the right direction.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Import File Requirements<\/h3>\n\n\n\n<p>Your import file will require 4 columns:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Column Name: Product Type<\/h4>\n\n\n\n<p>This will be used in the <strong>Set Product Type With XPath<\/strong> option, and the value will either be&nbsp;<strong>grouped<\/strong>&nbsp;or&nbsp;<strong>simple<\/strong>. Usage example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath.jpg\" data-rel=\"lightbox-image-13\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"278\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath-1024x278.jpg\" alt=\"Import Grouped Products Set Product Type with XPath\" class=\"wp-image-5819506\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath-1024x278.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath-300x81.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath-768x208.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath-1536x416.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Set-Product-Type-with-XPath.jpg 1904w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Column Name: Sub-Product Type<\/h4>\n\n\n\n<p>This will be used to determine whether the product should be grouped with a parent product, and the value will either be&nbsp;<strong>grouped<\/strong>&nbsp;or&nbsp;simple.<\/p>\n\n\n\n<p>You will use the field with an XPath IF Statement in the <strong>Name<\/strong> field via&nbsp;<strong>Linked Products \u203a Manual Grouped Product Matching \u203a Match by Custom Field<\/strong>:<\/p>\n\n\n\n<p>Here's the IF Statement (<a href=\"https:\/\/www.wpallimport.com\/documentation\/if-statements\/#inline-if\" target=\"_blank\" rel=\"noreferrer noopener\">learn more<\/a>):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"xpath\"><pre class=\"line-numbers\"><code class=\"language-xpath\">[IF({subproducttype[1][.=&quot;grouped&quot;]})]groupid[ELSE][ENDIF]<\/code><\/pre><\/div>\n\n\n\n<p>Usage example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab.jpg\" data-rel=\"lightbox-image-14\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"696\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-1024x696.jpg\" alt=\"Import Grouped Products Linked Products Tab\" class=\"wp-image-5819507\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-1024x696.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-300x204.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-768x522.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-1536x1044.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab.jpg 1910w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Column Name: Group ID<\/h4>\n\n\n\n<p>This should only have a value for Grouped products. It will be used to link Simple products to the group. You'll import the element into a Custom Field named \"groupid\". Usage example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field.jpg\" data-rel=\"lightbox-image-15\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"266\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field-1024x266.jpg\" alt=\"Import Grouped Products Group ID Custom Field\" class=\"wp-image-5819508\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field-1024x266.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field-300x78.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field-768x200.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field-1536x399.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Group-ID-Custom-Field.jpg 1894w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Column Name: Group Match<\/h4>\n\n\n\n<p>This should only have a value for simple products, and it should contain the group ID value for the parent (grouped) product that the current record belongs to.<\/p>\n\n\n\n<p>You will use the field in the <strong>Value<\/strong> field via&nbsp;<strong>Linked Products \u203a Manual Grouped Product Matching \u203a Match by Custom Field<\/strong>. Usage example:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match.jpg\" data-rel=\"lightbox-image-16\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"697\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match-1024x697.jpg\" alt=\"Import Grouped Products Linked Products Tab Group Match\" class=\"wp-image-5819509\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match-1024x697.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match-300x204.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match-768x523.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match-1536x1046.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Import-Grouped-Products-Linked-Products-Tab-Group-Match.jpg 1892w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>By setting up the import process like that, you'll be able to import both grouped products and their grouped simple products in the same import process.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example Files and Import Template to Use<\/h3>\n\n\n\n<p>You can test the above steps on a free demo site at&nbsp;<a href=\"http:\/\/wpallimport.com\/try\/\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/wpallimport.com\/try\/<\/a>.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Import Template (downloads a .ZIP file, unzip it, and install the .TXT via <strong>All Import \u203a Settings<\/strong>):&nbsp;<a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/templates_5c3e320a000d3.txt.zip\" target=\"_blank\" rel=\"noreferrer noopener\">template.txt<\/a> <\/li>\n\n\n\n<li>Import File:&nbsp;<a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/grouped_and_simple_products.csv\" target=\"_blank\" rel=\"noreferrer noopener\">grouped_and_simple_products.csv<\/a><\/li>\n<\/ul>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#adjust-prices-based-on-the-price-range\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"adjust-prices-based-on-the-price-range\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#adjust-prices-based-on-the-price-range\" class=\"snippet-title\"><h2><strong>Adjust Prices Based on The Price Range<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>You can use a PHP function like this to adjust the prices based on a price range:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_adjust_range( $price ) {\n    switch ( true ) {\n        case ( $price &gt;= 0 &amp;&amp; $price &#x3C;= 10 ):\n            $adjustment = 1.7;\n            break;\n        case ( $price &gt; 10 &amp;&amp; $price &#x3C;= 20 ):\n            $adjustment = 1.6;\n            break;\n        case ( $price &gt; 20 &amp;&amp; $price &#x3C;= 30 ):\n            $adjustment = 1.5;\n            break;        \n        default:\n            $adjustment = 1;\n            break;\n    }\n    return round( $price * $adjustment, 2 );\n}<\/code><\/pre><\/div>\n\n\n\n<p>This is used in the regular price import field:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range.jpg\" data-rel=\"lightbox-image-17\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"618\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range-1024x618.jpg\" alt=\"Adjust Prices Based on Price Range\" class=\"wp-image-5819634\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range-1024x618.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range-300x181.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range-768x463.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range-1536x927.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Adjust-Prices-Based-on-Price-Range.jpg 1850w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#store-images-using-sources-path\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"store-images-using-sources-path\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#store-images-using-sources-path\" class=\"snippet-title\"><h2><strong>Store Images Using Source's Path<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet shows you how to store the downloaded images in a custom folder structure that matches the source's path.<\/p>\n\n\n\n<p><strong>Step 1:<\/strong><\/p>\n\n\n\n<p>Copy and paste the following code into your theme's child functions.php file, or use a plugin like Code Snippets (see&nbsp;<a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/wordpress.org\/plugins\/code-snippets\/<\/a>).<\/p>\n\n\n\n<p>Here we use the <a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_import_single_image_uploads_dir\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_import_single_image_uploads_dir<\/a> hook to get an external image's path and use it to store the downloaded images in that same path in the new site.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_filter( 'wp_all_import_single_image_uploads_dir', 'wpai_wp_all_import_single_image_uploads_dir', 10, 6 );\nfunction wpai_wp_all_import_single_image_uploads_dir( $uploads, $image_url, $articleData, $current_xml_node, $import_id, $post_id ) {\n    $path = soflyy_extract_path($image_url);\n    $uploads['path'] = $uploads['basedir'] . '\/' . $path;\n    $uploads['url'] = $uploads['baseurl'] . '\/' . $path;\n    wp_mkdir_p($uploads['path']);\n    return $uploads;\n}<\/code><\/pre><\/div>\n\n\n\n<p><strong>Step 2:<\/strong><\/p>\n\n\n\n<p>Set up your import and paste the following code in the <strong>Function Editor<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_extract_path($ftppath) {\n    $parts = explode('\/', $ftppath);\n    \/\/ Change 'img' with your desired path part\n    $index = array_search('img', $parts);\n\n    if ($index !== false) {\n        $path = implode('\/', array_slice($parts, $index + 1));\n        return $path;\n    }\n\n    return '';\n}<\/code><\/pre><\/div>\n\n\n\n<p>Change 'img' with your desired path part. The function will look for this part and return everything that comes after it (e.g. if the image's source is '\/img\/test-1\/test-child\/image-1.jpg', then the path in the target site will be '\/wp-content\/uploads\/test-1\/test-child\/').<\/p>\n\n\n\n<p>Once your changes are done, call the function like this:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[soflyy_extract_path({your_image_element[1]})]<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#update-variable-products-stock-and-price-by-title\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"update-variable-products-stock-and-price-by-title\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#update-variable-products-stock-and-price-by-title\" class=\"snippet-title\"><h2><strong>Update Variable Products Stock and Price by Title<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet helps you update price and stock values for WooCommerce variable products using only the product title and attributes. This is useful when you don't have a file with SKUs or variation IDs to match with your existing variations. <\/p>\n\n\n\n<p>Before using this snippet, it is really important to back up your database so that you can roll back if needed.<\/p>\n\n\n\n<p>This snippet loops through all variations finding a match between the record being imported and the variation. Then, it updates price and stock values for each variation, matching based on the provided color and size passed in the Custom Fields section.<\/p>\n\n\n\n<p>If you have other variations with those same two attribute values, plus other attributes, those variations are updated as well.<\/p>\n\n\n\n<p>First, create two custom fields for '_tmp_price' and '_tmp_stock_quantity', and '_tmp' custom fields for your attributes, and assign them the values from your file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields.jpg\" data-rel=\"lightbox-image-18\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"448\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields-1024x448.jpg\" alt=\"Update Variable Stock Price by Title Custom Fields\" class=\"wp-image-5820123\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields-1024x448.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields-300x131.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields-768x336.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields-1536x672.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2023\/09\/Update-Variable-Stock-Price-by-Title-Custom-Fields.jpg 1824w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Then, change\/add the attributes for your products in the code, as well as the import ID check.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function update_variation_prices_by_title( $post_id, $xml_node, $is_update ) {\n\t\/\/ Retrieve the import ID.\n\t$import_id = wp_all_import_get_import_id(); \n\t\/\/ Only run for import 8.     \n\tif ( $import_id == '8' ) {\n\t\t$product = wc_get_product($post_id);\n\t\tif ($product &amp;&amp; $product-&gt;is_type('variable')) {\n\t\t\t$parent_title = $product-&gt;get_title();\n\t\t\t$variations = $product-&gt;get_children();\n\n\t\t\t\/\/ Retrieve the temporary color and size values from the import file\n\t\t\t\/\/ Change\/add your attributes here\n\t\t\t$tmp_color = get_post_meta($import_id, '_tmp_color', true);\n\t\t\t$tmp_size = get_post_meta($import_id, '_tmp_size', true);\n\n\t\tforeach ($variations as $variation_id) {\n\t\t\t$variation = wc_get_product($variation_id);\n\n\t\t\tif ($variation &amp;&amp; $variation-&gt;get_title() == $parent_title) {\n\t\t\t\t\/\/ Get the color and size attributes of the current variation\n\t\t\t\t\/\/ Change\/add your attributes here\n\t\t\t\t$variation_color = $variation-&gt;get_attribute('color');\n\t\t\t\t$variation_size = $variation-&gt;get_attribute('size');\n\n\t\t\t\/\/ Check if the variation attributes match those in the import file\n\t\t\t\/\/ Change\/add your attributes here\n\t\t\tif ($variation_color == $tmp_color &amp;&amp; $variation_size == $tmp_size) {\n\t\t\t\t$tmp_price = get_post_meta($import_id, '_tmp_price', true);\n\t\t\t\t$tmp_stock_quantity = get_post_meta($import_id, '_tmp_stock_quantity', true);\n\n\t\t\tif ($tmp_price !== '') {\n\t\t\t\tupdate_post_meta($variation_id, '_price', $tmp_price);\n\t\t\t\tupdate_post_meta($variation_id, '_regular_price', $tmp_price);\n\t\t\t\t}\n\n\t\t\tif ($tmp_stock_quantity !== '') {\n\t\t\t\tupdate_post_meta($variation_id, '_stock', $tmp_stock_quantity);\n\t\t\t\t}\n\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdelete_post_meta($import_id, '_tmp_price');\n\t\tdelete_post_meta($import_id, '_tmp_stock_quantity');\n\t\tdelete_post_meta($import_id, '_tmp_color');\n\t\tdelete_post_meta($import_id, '_tmp_size');\n\t\t}\n\t}\n}\nadd_action('pmxi_saved_post', 'update_variation_prices_by_title', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#if-no-variation-image-export-parent-image-as-fallback\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"if-no-variation-image-export-parent-image-as-fallback\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#if-no-variation-image-export-parent-image-as-fallback\" class=\"snippet-title\"><h2><strong>If No Variation Image, Export Parent Image as Fallback<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This code returns the parent image as a fallback if there is no variation image available. <\/p>\n\n\n\n<p>To use the code, add a new ID field in your export, enable <strong>Export the value returned by a PHP function,<\/strong> and input the function name. <\/p>\n\n\n\n<p>Here's the code to save in the <strong>Function Editor<\/strong>:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_soflyy_get_image($post_id) {\n    $product = wc_get_product($post_id);\n\n    \/\/ If there's no product for some reason, return null\n    if (!$product) {\n        return null;\n    }\n\n    $image_id = $product-&gt;get_image_id();\n\n    \/\/ If the product is a variation and doesn't have an image, get the parent image\n    if ($product-&gt;is_type('variation') &amp;&amp; !$image_id) {\n        $parent_product = wc_get_product($product-&gt;get_parent_id());\n        $image_id = $parent_product-&gt;get_image_id();\n    }\n\n    \/\/ Get the image URL\n    $image_url = wp_get_attachment_url($image_id);\n\n    return $image_url;\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#use-the-second-image-if-the-first-image-is-not-valid\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"use-the-second-image-if-the-first-image-is-not-valid\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#use-the-second-image-if-the-first-image-is-not-valid\" class=\"snippet-title\"><h2><strong>Use the Second Image if the First Image Is Not Valid<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This code checks if the first image is valid. If it is, it returns both images. If not, it returns only the second one.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_check_images($image1, $image2) {\n\n    $headers = @get_headers($image1);\n    \/\/ Checks if the image URL is valid &amp; if it is returns both image1 and image2\n    if ($headers &amp;&amp; strpos( $headers[0], '200')) {\n\n        return $image1 . \",\" . $image2;\n    \/\/ If not, returns image2\n    } else {\n\n        return $image2;\n    }\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#filter-export-data-with-multiple-filters\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"filter-export-data-with-multiple-filters\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#filter-export-data-with-multiple-filters\" class=\"snippet-title\"><h2><strong>Filter Export Data with Multiple Filters<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet helps you programmatically filter export data with multiple filters. Read the comments carefully and make the necessary adjustments for it to work on your site with your data.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">\/**\n * This function filters orders by multiple criteria:\n * - Only export orders that came in before the year 2018\n * - Only export orders with \"wc-processing\" or \"wc-completed\" as the status\n * - Only export orders that have at least 1 product in the \"Heart Shaped\" product category\n * \n * You need to make the following changes:\n * - Change \"2\" to your export ID.\n * - Change \"Heart Shaped\" to the category you want to be exported.\n * - Change \"2018-01-01 00:00:00\" and\/or the date comparison to match the date(s) you want.\n * \n * !!! IMPORTANT NOTES !!!\n * - The \"Display each product in its own row\" option in the export template must be ENABLED.\n * - The \"Fill in empty columns\" option in the export template must be DISABLED.\n * - The \"my_check_if_in_product_cat\" helper function below must be saved in the function editor as well.\n * - The export count won't change, but only the filtered orders will be in the final export file.\n *\/\nfunction my_wp_all_export_csv_rows( $articles, $options, $export_id ) {\n    \/\/ Only run for export ID 2\n    if ( $export_id != 2 ) {\n        return $articles;\n    }\n\n    \/\/ Set up an array to store the orders that pass the filters.\n\t$allowed_orders = array();\n\t\n    \/\/ Loop through each export record\n    foreach ( $articles as $key =&gt; $article ) {\n        \/\/ Get the data we need for our filters.\n\t\t$date   = $article['Order Date'];\n\t\t$status = $article['Order Status'];\n\t\t$in_cat = my_check_if_in_product_cat( $article['Product ID'], 'Heart Shaped' );\n\n        \/\/ If status is not wc-processing or wc-completed, do not add to allowed orders.\n\t\tif ( $status != 'wc-processing' &amp;&amp; $status != 'wc-completed' ) {\n\t\t\tcontinue;\n\t\t}\n\n        \/\/ If product is not in the \"Heart Shaped\" category, do not add to allowed orders.\n\t\tif ( $in_cat == false ) {\n\t\t\tcontinue;\n\t\t}\n\n        \/\/ If order date is in 2018 or newer, do not add to allowed orders.\n\t\tif ( strtotime( $date ) &gt;= strtotime( '2018-01-01 00:00:00' ) ) {\n\t\t\tcontinue;\n\t\t}\n\t\t\n        \/\/ If the code gets here, the order ID passed all of the checks, so we add it to allowed orders.\n\t\t$allowed_orders[] = $article['Order ID'];\n\t}\n\t\n\t\/\/ Remove all disallowed orders.\n\tforeach ( $articles as $key =&gt; $article ) {\n\t\tif ( ! in_array( $article['Order ID'], $allowed_orders ) ) {\n\t\t\tunset( $articles[ $key ] );\t\n\t\t}\n\t}\n\n\t\/\/ Return the allowed orders.\n\treturn isset($articles[0]) ? $articles : $articles[0] = [];\n}\nadd_filter( 'wp_all_export_csv_rows', 'my_wp_all_export_csv_rows', 10, 3 );\n\n\/\/ Checks if a product is in a specified category.\nfunction my_check_if_in_product_cat( $item_id = array(), $category = '' ) {\n\tif ( empty( $category ) || empty( $item_id ) ) {\n\t\treturn false;\n\t}\n\n\t$terms = get_the_terms( $item_id, 'product_cat' );\n    \n\tforeach ( $terms as $term ) {\n\t\tif ( $category == $term-&gt;name ) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn false;\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#change-uploads-folder-during-import\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"change-uploads-folder-during-import\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#change-uploads-folder-during-import\" class=\"snippet-title\"><h2><strong>Change Uploads Folder During Import<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This is a standalone snippet that can be used to change where things are uploaded during the import. The code would need to be added to a code snippets plugin like <a href=\"https:\/\/wpcodebox.com\/\">WPCodeBox<\/a>.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">$import_id = wp_all_import_get_import_id();\n\nif ( $import_id == '1' ) {\n\tadd_filter('upload_dir', 'add_to_uploads_dir');\n\n\tfunction add_to_uploads_dir( $param ) {\n    \t    $dir = '\/somecustomfolder';\n    \t    $param['path'] = $param['path'] . $dir;\n    \t    $param['url'] = $param['url'] . $dir;\n    \t    return $param;\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#assign-a-post-parent-programmatically\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"assign-a-post-parent-programmatically\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#assign-a-post-parent-programmatically\" class=\"snippet-title\"><h2><strong>Assign A Post Parent Programmatically<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>The code below will look for a parent to match, so the parent posts should be imported first. <\/p>\n\n\n\n<p>You should add a Custom Field named \"_tmp_parent_value\", the value should either be the Post ID or the exact title. <\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_action( 'pmxi_saved_post', 'set_parent_page', 10, 1 );\nfunction set_parent_page( $pid ) {\n\t$page = get_post( $pid );\n\tif ( ! empty( $page ) ) {\n\t\t$parent_page = get_post_meta( $pid, '_tmp_parent_value', true );\n\t\tif ( ! is_numeric( $parent_page ) ) {\n\t\t\t$parent = get_page_by_title( $parent_page );\n\t\t\tif ( ! empty( $parent ) ) {\n\t\t\t\t$parent_page = $parent-&gt;ID;\n\t\t\t}\n\t\t}\n\t\tif ( is_numeric( $parent_page ) ) {\n\t\t\twp_update_post( array(\n\t\t\t\t'ID' =&gt; $page-&gt;ID,\n\t\t\t\t'post_parent' =&gt; $parent_page\n\t\t\t) );\n\t\t}\n\t\tdelete_post_meta( $pid, '_tmp_parent_value' );\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#get-post-id-by-custom-field\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"get-post-id-by-custom-field\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#get-post-id-by-custom-field\" class=\"snippet-title\"><h2><strong>Get Post ID By Custom Field<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This code lets you obtain a post ID by passing a custom field's name and value to this function. <\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function get_post_id_by_meta_key_and_value( $key, $value ) {\n\tglobal $wpdb;\n\t$meta = $wpdb-&gt;get_results( \"SELECT * FROM `\" . $wpdb-&gt;postmeta . \"` WHERE meta_key='\" . $wpdb-&gt;escape( $key ) . \"' AND meta_value='\" . $wpdb-&gt;escape( $value ) . \"'\" );\n\tif ( is_array( $meta ) &amp;&amp; !empty( $meta ) &amp;&amp; isset( $meta[0] ) ) {\n\t\t$meta = $meta[0];\n\t} \n\tif ( is_object( $meta ) ) {\n\t\treturn $meta-&gt;post_id;\n\t} else {\n\t\treturn false;\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#extract-url-from-a-string\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"extract-url-from-a-string\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#extract-url-from-a-string\" class=\"snippet-title\"><h2><strong>Extract URL From a String<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This function is used to extract or pull a URL from a text string.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function echo_url( $string ) {\n    preg_match_all('#\\bhttps?:\/\/[^\\s()]+(?:\\([\\w\\d]+\\)|([^[:punct:]\\s]|\/))#', $string, $match);\n    return  $match[0][0];\n}<\/code><\/pre><\/div>\n\n\n\n<p>Used like so:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[echo_url({import_element[1]})]<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#limit-depth-of-categories\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"limit-depth-of-categories\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#limit-depth-of-categories\" class=\"snippet-title\"><h2><strong>Limit the Depth of Categories<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This function can be used when importing categories to limit how much depth the taxonomy hierarchy should have.<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function stripCat( $input = null, $depth = 2, $sep = '&gt;' ) {    \n\tif ( $input != null ) {\n\t\t$pieces = explode( $sep, $input );\n\t\t$i = 0;\n\t\t$output = $pieces[$i];\n\t\tif ( count( $pieces ) &lt; $depth ) {\n\t\t\t$depth = count($pieces);\n\t\t}\n\t\twhile ( $i  ' . $pieces[$i];\n\t\t}\n\t\treturn $output;\n\t}\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#calculate-order-totals-based-on-product-price\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"calculate-order-totals-based-on-product-price\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#calculate-order-totals-based-on-product-price\" class=\"snippet-title\"><h2><strong>Calculate Order Totals Based on Product Price<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<h3 class=\"wp-block-heading\" id=\"user-content-instructions\">Instructions:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use this code in your Function Editor and leave the Totals field empty.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"user-content-disclaimer\">Disclaimer:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This will work with your import using the current tax rates, it won't work for any past rates.<\/li>\n\n\n\n<li>Keep in mind that this is an example function, and you may need to modify it to work on your site.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_recalc_order( $post_id, $xml_node, $is_update ) {\n\n    \/\/ Retrieve the import ID.\n    $import_id = wp_all_import_get_import_id(); \n\n    \/\/ Change '1' to your import ID.\n    if ( $import_id == '1' ) {\n        $order = new \\WC_Order( $post_id );\n        $order-&gt;calculate_totals( );\n    }\n}\nadd_action( 'pmxi_saved_post', 'my_recalc_order', 10, 3 );<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#export-acf-nested-repeaters\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"export-acf-nested-repeaters\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#export-acf-nested-repeaters\" class=\"snippet-title\"><h2><strong>Export ACF Nested Repeaters<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Here's example code that lets you export ACF nested repeaters. Example field:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-scaled.jpg\" data-rel=\"lightbox-image-19\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"605\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-1024x605.jpg\" alt=\"\" class=\"wp-image-5834849\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-1024x605.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-300x177.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-768x454.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-1536x908.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-2048x1210.jpg 2048w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-scaled.jpg 2560w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Example data:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-scaled.jpg\" data-rel=\"lightbox-image-20\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"616\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-1024x616.jpg\" alt=\"ACF Nested Repeater Example Data\" class=\"wp-image-5834851\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-1024x616.jpg 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-300x180.jpg 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-768x462.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-1536x923.jpg 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-2048x1231.jpg 2048w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Data-scaled.jpg 2560w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Example code:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_nested_data($parent_repeater_name = \"\", $nested_repeater_name = \"\", $field_name = \"\", $post_id = null, $image = false, $separator = \"|\") {\n    $output = [];\n    if( have_rows($parent_repeater_name, $post_id) ) {\n        while( have_rows($parent_repeater_name, $post_id) ) {\n            the_row();\n            $nested_output = []; \/\/ Initialize an array to hold nested repeater field data\n            if( have_rows($nested_repeater_name, $post_id) ) {\n                while( have_rows($nested_repeater_name, $post_id) ) {\n                    the_row();\n                    $field_data = get_sub_field($field_name);\n                    if ($image &amp;&amp; filter_var($field_data, FILTER_VALIDATE_URL) === FALSE) {\n                        $field_data = (is_array($field_data) &amp;&amp; isset($field_data['url'])) ? $field_data['url'] : $field_data;\n                    }\n                    $nested_output[] = $field_data; \/\/ Add to the nested output array\n                }\n            }\n            $output[] = implode(';', $nested_output); \/\/ Implode nested data with ';' and add to the main output array\n        }\n    }\n    return implode($separator, $output); \/\/ Implode the main output array with '|'\n}<\/code><\/pre><\/div>\n\n\n\n<p>Used like so in a Custom Export Field:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage.jpg\" data-rel=\"lightbox-image-21\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1003\" height=\"1024\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage-1003x1024.jpg\" alt=\"ACF Nested Repeater Example Usage\" class=\"wp-image-5834852\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage-1003x1024.jpg 1003w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage-294x300.jpg 294w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage-768x784.jpg 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage-1505x1536.jpg 1505w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/01\/ACF-Nested-Repeater-Example-Usage.jpg 1762w\" sizes=\"(max-width: 1003px) 100vw, 1003px\" \/><\/a><\/figure>\n\n\n\n<p>Here's the code used:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[my_nested_data(\"my_repeater\", \"my_nested_repeater\", \"my_text_field\", {ID})]\n[my_nested_data(\"my_repeater\", \"my_nested_repeater\", \"my_image_field\", {ID}, true)]<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#use-existing-variation-prices-for-variations-without-price\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"use-existing-variation-prices-for-variations-without-price\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#use-existing-variation-prices-for-variations-without-price\" class=\"snippet-title\"><h2><strong>Use Existing Variation Prices for Variations without Price<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This function uses the '<a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#wp_all_import_before_variable_product_import\" target=\"_blank\" rel=\"noreferrer noopener\">wp_all_import_before_variable_product_import<\/a>' action to import\/update variations that have no price by using the price of an existing variation within the same parent product.<\/p>\n\n\n\n<p>Just paste the code below in the Function Editor:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_before_variable_product_import($product_id) {\n    global $wpdb;\n\n    $product = wc_get_product($product_id);\n    if ($product &amp;&amp; $product-&gt;is_type('variable')) {\n        $children = $product-&gt;get_children();\n\n        \/\/ Query to get the first variation with a price\n        $price_query = \"SELECT meta_value FROM {$wpdb-&gt;postmeta} WHERE post_id IN (\" . implode(',', $children) . \") AND meta_key = '_price' AND meta_value &gt; '' ORDER BY meta_id ASC LIMIT 1\";\n        $price = $wpdb-&gt;get_var($price_query);\n\n        \/\/ Check if a price is found\n        if (!empty($price)) {\n            \/\/ Loop through each child and set the price\n            foreach ($children as $child_id) {\n                update_post_meta($child_id, '_price', $price);\n                update_post_meta($child_id, '_regular_price', $price);\n                \n                \/\/ Update the product object and save it\n                $child_product = wc_get_product($child_id);\n                if ($child_product) {\n                    $child_product-&gt;set_price($price);\n                    $child_product-&gt;set_regular_price($price);\n                    $child_product-&gt;save();\n                }\n            }\n        }\n    }\n}\nadd_action('wp_all_import_before_variable_product_import', 'my_before_variable_product_import', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#programmatically-remove-imported-images-that-are-no-longer-available\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"programmatically-remove-imported-images-that-are-no-longer-available\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#programmatically-remove-imported-images-that-are-no-longer-available\" class=\"snippet-title\"><h2><strong>Programmatically Remove Imported Images That Are No Longer Available<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>The following code snippet lets you programmatically remove existing images that are no longer available in your import file, while leaving the option<strong> Keep images currently in Media Library<\/strong> enabled. The snippet lets you do the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Removes image when the URL is removed<\/li>\n\n\n\n<li>Reimports image when the URL is re-added<\/li>\n\n\n\n<li>Updates the featured image when the URL is changed<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function soflyy_img_import( $post_id, $gallery_attachment_ids, $missing_images ) {\n    \/\/ Check if there are any missing images to process\n    if ( empty($missing_images) ) {\n        return; \/\/ Exit if no missing images are found\n    }\n    \n    \/\/ Ensure the featured image is not considered for deletion\n    $thumbnail_id = get_post_thumbnail_id( $post_id );\n    if (!in_array($thumbnail_id, $gallery_attachment_ids)) {\n        $gallery_attachment_ids[] = $thumbnail_id;\n    }\n    \n    \/\/ Identify the actual images to delete\n    $images_to_delete = array_diff($missing_images, $gallery_attachment_ids);\n    \n    \/\/ Delete the identified images\n    foreach ($images_to_delete as $image_id) {\n        wp_delete_attachment($image_id, true);\n    }\n}\nadd_action('wpallimport_after_images_import', 'soflyy_img_import', 10, 3);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#how-to-import-jetengine-relations\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"how-to-import-jetengine-relations\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#how-to-import-jetengine-relations\" class=\"snippet-title\"><h2><strong>How to Import JetEngine Relations<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This snippet will work for One to One, One to Many and Many to Many relationships:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We use the '<a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_saved_post<\/a>' hook to import relations with different relationship types.<\/li>\n<\/ul>\n\n\n\n<p><strong>Instructions:<\/strong><a href=\"https:\/\/gist.github.com\/juanlistab\/7ea24b4154313075539101a12cbf5731#instructions\"><\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a \"_temp_child\" temporary field to store the values of the relations you want to import. It will accept multiple values separated with commas, and you can use either the ID or the Title. See:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Temp-Field-Import-JetEngine-Relations.png\" data-rel=\"lightbox-image-22\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"454\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Temp-Field-Import-JetEngine-Relations-1024x454.png\" alt=\"Temp Field Import JetEngine Relations\" class=\"wp-image-5845375\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Temp-Field-Import-JetEngine-Relations-1024x454.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Temp-Field-Import-JetEngine-Relations-300x133.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Temp-Field-Import-JetEngine-Relations-768x341.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Temp-Field-Import-JetEngine-Relations.png 1366w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Edit the snippet using the instructions below and paste it into the Function Editor inside WP All Import (<strong>All Import<\/strong> \u203a <strong>Settings<\/strong> \u203a <strong>Function Editor<\/strong>).<\/li>\n\n\n\n<li>The \"jet_rel_default\" table is the default table used for relations in JetEngine. If you're using a separate table, you'll need to set that table's name instead.<\/li>\n\n\n\n<li>You'll need to specify the relationship ID in 'rel_id\u2019; you can find it here:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example.png\" data-rel=\"lightbox-image-23\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"569\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example-1024x569.png\" alt=\"Relation ID Example\" class=\"wp-image-5845376\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example-1024x569.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example-300x167.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example-768x427.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example-1536x853.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example-2048x1138.png 2048w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Relation-ID-Example.png 2866w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_import_je_relations ($id) {\n    \n    global $wpdb;\n\n    \/\/ Change \"_temp_child\" to the temp field you set up in Custom Fields\n    $child_identifiers = get_post_meta($id, '_temp_child', true);\n\n    \/\/ Check if there are multiple identifiers in '_temp_child', separated by commas.\n    $child_identifiers = explode(',', $child_identifiers);\n\n    \/\/ The \"jet_rel_default\" table is the default JetEngine value, if your using a custom DB table for relations, change it here\n    $table_name = $wpdb->prefix . \"jet_rel_default\";\n\n    \/\/ Loop through as many \"_temp_child\" elements there are inserting them in the DB as new rows\n    foreach ($child_identifiers as $child_identifier) {\n        \/\/ Trim spaces and check if the identifier is numeric or a title.\n        $child_identifier = trim($child_identifier);\n        $child_id = false;\n\n        \/\/ Checks if the _temp_child field is numeric, meaning an ID    \n        if (is_numeric($child_identifier)) {\n            $child_id = $child_identifier;\n        } else {\n            \/\/ If it's not numeric, assume it's a title and look up the corresponding ID.\n            \/\/ Replace 'post-child' with your actual post type.\n            $child_post = wp_all_import_get_page_by_title($child_identifier); \n            if ($child_post) {\n                $child_id = $child_post->ID;\n            }\n        }\n\n        if ($child_id) {\n            \/\/ Insert the relationship ID in 'rel_id', and the Parent relationship in 'parent_rel' \n            $data_to_insert = array(\n                'parent_object_id' => $id,\n                'child_object_id' => $child_id,\n                'rel_id' => 1,\n                'parent_rel' => 0\n            );\n\n            $format = array('%d', '%d', '%d', '%d');\n\n            $wpdb->insert($table_name, $data_to_insert, $format);\n        }\n    }\n\n    delete_post_meta($id, '_temp_child');\n}\nadd_action('pmxi_saved_post', 'my_import_je_relations', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#how-to-export-jetengine-relations\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"how-to-export-jetengine-relations\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#how-to-export-jetengine-relations\" class=\"snippet-title\"><h2><strong>How to Export JetEngine Relations<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This function will use the default \"jet_rel_default\" table in JetEngine to look for the post_id of the parent and return its relations from the \"child_object_id\" column. If you're using a separate table for your relations, you can change the $table_name value.<\/p>\n\n\n\n<p><strong>Instructions:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add a New Field in WP All Export. See:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations.png\" data-rel=\"lightbox-image-24\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"674\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations-1024x674.png\" alt=\"Add Field JetEngine Relations\" class=\"wp-image-5845403\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations-1024x674.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations-300x197.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations-768x506.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations-1536x1011.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Field-JetEngine-Relations.png 1978w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set a name for the column and use <strong>ID<\/strong> for the field to export. See:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations.png\" data-rel=\"lightbox-image-25\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"871\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations-1024x871.png\" alt=\"Set Name and Use ID JetEngine Relations\" class=\"wp-image-5845404\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations-1024x871.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations-300x255.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations-768x653.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations-1536x1306.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Set-Name-and-Use-ID-JetEngine-Relations.png 1736w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Modify the function as needed, paste it in the Function Editor, and paste the name of the function in the <strong>Export the value returned by a PHP function<\/strong> field. See:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations.png\" data-rel=\"lightbox-image-26\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"873\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations-1024x873.png\" alt=\"Enable Function JetEngine Relations\" class=\"wp-image-5845405\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations-1024x873.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations-300x256.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations-768x655.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations-1536x1309.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Enable-Function-JetEngine-Relations.png 1734w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The function will return a list of IDs separated with pipes by default, but if you want to export the titles instead, you need to change the $mode in \"function my_export_je_relation ($post_id, $mode = 'id')\" to \"title\".<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">\/\/ Change \"id\" for \"title\" if you need to export the titles instead of IDs\nfunction my_export_je_relation ($post_id, $mode = 'id') {\n    global $wpdb;\n\n    \/\/ The \"jet_rel_default\" table is the default JetEngine value, if your using a custom DB table for relations, change it here\n    $table_name = $wpdb->prefix . \"jet_rel_default\";\n\n    \/\/ Fetch child object IDs related to the parent post ID.\n    $child_ids = $wpdb->get_col($wpdb->prepare(\"SELECT child_object_id FROM $table_name WHERE parent_object_id = %d\", $post_id));\n\n    \/\/ Default behaviour is to return the ID, but you can change the mode to \"title\" to export titles instead \n    if ('title' === $mode) {\n        \/\/ Get relations titles by ID\n        $titles = array_map(function($id) {\n            $post = get_post($id);\n            return $post ? $post->post_title : '';\n        }, $child_ids);\n\n        return implode('|', $titles);\n    }\n\n    return implode('|', $child_ids);\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#add-data-into-custom-fields-for-variations-using-child-xml-import-option\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"add-data-into-custom-fields-for-variations-using-child-xml-import-option\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#add-data-into-custom-fields-for-variations-using-child-xml-import-option\" class=\"snippet-title\"><h2><strong>Add Data into Custom Fields for Variations Using Child XML Import Option<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>The following snippet lets you import custom fields to variations when using the <strong>I'm importing XML, and my variations are child XML elements<\/strong> option.<\/p>\n\n\n\n<p>For example, let's say that you have an EAN value in your parent product, which you want to copy into all variations. You would define a custom field named \"_temp_variation_custom_field\" under your parent product with that EAN value, like so:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option.png\" data-rel=\"lightbox-image-27\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"242\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option-1024x242.png\" alt=\"Add Custom Field to Import Into Variation XML Option\" class=\"wp-image-5845410\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option-1024x242.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option-300x71.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option-768x182.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option-1536x363.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/Add-Custom-Field-to-Import-Into-Variation-XML-Option.png 1760w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>The function also accepts comma-separated strings as input if you want to import separate values for each variant.<\/p>\n\n\n\n<p>Just make sure that the code is saved in the function editor of WP All Import (<strong>All Import<\/strong> \u203a <strong>Settings<\/strong> \u203a <strong>Function Editor<\/strong>):<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">add_action( 'pmxi_saved_post', 'my_add_custom_fields_to_variations', 10, 1 );\nfunction my_add_custom_fields_to_variations($parent_product_id) {\n    $temp_custom_field_name = \"_temp_variation_custom_field\";\n    $variant_custom_field_name = \"woo_feed_ean\";\n\n    \/\/ Get the parent product object\n    $parent_product = wc_get_product($parent_product_id);\n\n    \/\/ Check if the parent product exists and is a variable product\n    if (!$parent_product || 'variable' !== $parent_product->get_type()) {\n        return;\n    }\n\n    \/\/ Get the comma-separated string from the parent product's custom field\n    $custom_field_values_string = get_post_meta($parent_product_id, $temp_custom_field_name, true);\n\n    \/\/ Convert the string to an array\n    $custom_field_values = explode(',', $custom_field_values_string);\n\n    \/\/ Get all variations of the parent product\n    $variation_ids = $parent_product->get_children();\n\n    \/\/ Iterate through each variation and assign the corresponding custom field value\n    foreach ($variation_ids as $index => $variation_id) {\n        if (isset($custom_field_values[$index])) {\n            \/\/ Update the custom field for the variation\n            update_post_meta($variation_id, $variant_custom_field_name, trim($custom_field_values[$index]));\n        }\n    }\n\n    \/\/ Optionally, delete the custom field from the parent product at the end\n    delete_post_meta($parent_product_id, $temp_custom_field_name);\n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-suppliers-to-the-atum-inventory-management-plugin\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-suppliers-to-the-atum-inventory-management-plugin\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-suppliers-to-the-atum-inventory-management-plugin\" class=\"snippet-title\"><h2><strong>Import Suppliers to the ATUM Inventory Management for WooCommerce plugin<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>The following function will import data to the ATUM Inventory Management for WooCommerce, more specifically, to the \"Supplier\" field using a temporary Custom Field and the '<a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#pmxi_saved_post\">pmxi_saved_post<\/a>' hook.<\/p>\n\n\n\n<p><strong>Instructions:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add a new Custom Field in WP All Import and name it \"_temp_supplier\". See:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field.png\" data-rel=\"lightbox-image-28\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"306\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field-1024x306.png\" alt=\"\" class=\"wp-image-5845962\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field-1024x306.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field-300x90.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field-768x230.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field-1536x459.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Supplier-Custom-Field.png 1860w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>That field will store the name of the supplier in the import file, and it'll be used to get that supplier's ID from the database. Keep in mind that this will not create new suppliers, so they need to exist on the site before running the import.<\/li>\n\n\n\n<li>Paste the function from below in the Function Editor (<strong>All Import \u203a Settings<\/strong>).<\/li>\n\n\n\n<li>The function will use the ID obtained from the supplier's name in the 'atum_product_data' table, 'supplier_id' column, for each imported product.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function save_data_to_custom_database_table($id) {\n    global $wpdb; \/\/ Make wpdb object available\n\n    \/\/ Retrieve value from '_temp_supplier' meta key\n    $temp_supplier = get_post_meta($id, '_temp_supplier', true);\n\n    \/\/ Check if 'temp_supplier' post exists\n    $temp_supplier_post_id = $wpdb->get_var(\n        $wpdb->prepare(\n            \"SELECT ID FROM $wpdb->posts WHERE post_title = %s\",\n            $temp_supplier\n        )\n    );\n\n    \/\/ Define target database table\n    $table_name = $wpdb->prefix . \"atum_product_data\";\n\n    if ($temp_supplier_post_id) {\n        \/\/ Check if the record already exists\n        $exists = $wpdb->get_var(\n            $wpdb->prepare(\n                \"SELECT COUNT(*) FROM $table_name WHERE product_id = %d\",\n                $id\n            )\n        );\n\n        \/\/ Update or insert value into database table\n        if ($exists) {\n            $wpdb->update(\n                $table_name,\n                ['supplier_id' => $temp_supplier_post_id],\n                ['product_id' => $id],\n                ['%d'],\n                ['%d']\n            );\n        } else {\n            $wpdb->insert(\n                $table_name,\n                ['product_id' => $id, 'supplier_id' => $temp_supplier_post_id],\n                ['%d', '%d']\n            );\n        }\n    }\n\n    \/\/ Delete temporary custom field\n    delete_post_meta($id, '_temp_supplier');\n}\nadd_action('pmxi_saved_post', 'save_data_to_custom_database_table', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#import-barcodes-to-the-atum-inventory-management-plugin\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"import-barcodes-to-the-atum-inventory-management-plugin\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#import-barcodes-to-the-atum-inventory-management-plugin\" class=\"snippet-title\"><h2><strong>Import Barcodes to the ATUM Inventory Management for WooCommerce plugin<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>This function will import data to the ATUM Inventory Management for WooCommerce, more specifically, to the \"Barcode\" field using a temporary Custom Field and the '<a href=\"https:\/\/www.wpallimport.com\/documentation\/action-reference\/#pmxi_saved_post\" target=\"_blank\" rel=\"noreferrer noopener\">pmxi_saved_post<\/a>' hook.<\/p>\n\n\n\n<p><strong>Instructions:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add a new Custom Field in WP All Import and name it \"_temp_barcode\". See:<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field.png\" data-rel=\"lightbox-image-29\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"1024\" height=\"299\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field-1024x299.png\" alt=\"ATUM Import Barcode Custom Field\" class=\"wp-image-5845968\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field-1024x299.png 1024w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field-300x88.png 300w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field-768x224.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field-1536x449.png 1536w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/05\/ATUM-Import-Barcode-Custom-Field.png 1800w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Paste the function in the Function Editor (<strong>All Import \u203a Settings<\/strong>).<\/li>\n\n\n\n<li>The function will use the data from the temp field and insert it in the 'atum_product_data' table, 'barcode' column, for each imported product.<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function save_data_to_custom_database_table($id) {\n    global $wpdb; \/\/ Make wpdb object available\n\n    \/\/ Retrieve value to save\n    $value = get_post_meta($id, '_temp_barcode', true);\n\n    \/\/ Define target database table\n    $table_name = $wpdb->prefix . \"atum_product_data\";\n\n    \/\/ Check if the record already exists\n    $exists = $wpdb->get_var($wpdb->prepare(\"SELECT COUNT(*) FROM $table_name WHERE product_id = %s\", $id));\n\n    \/\/ Update or insert value into database table\n    if ($exists) {\n        $wpdb->update($table_name, ['barcode' => $value], ['product_id' => $id], ['%s'], ['%s']);\n    } else {\n        $wpdb->insert($table_name, ['product_id' => $id, 'barcode' => $value], ['%s','%s']);\n    }\n\n    \/\/ Delete temporary custom field\n    delete_post_meta($id, '_temp_barcode');\n}\nadd_action('pmxi_saved_post', 'save_data_to_custom_database_table', 10, 1);<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#modify-import-options-programmatically\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"modify-import-options-programmatically\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#modify-import-options-programmatically\" class=\"snippet-title\"><h2><strong>Modify Import Options Programmatically<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>The hook 'wp_all_import_before_preserve_post_data' allows you to manipulate the import options on the fly. For example, to change the <strong>Choose which data to update<\/strong> settings while an import is running. Here is how to use this hook in a snippet:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">\/\/ Modifying import option before import post.\nadd_action('wp_all_import_before_preserve_post_data', 'wpai_wp_all_import_before_preserve_post_data', 10, 3);\nfunction wpai_wp_all_import_before_preserve_post_data($import, $pid, $artcleData) {\n    $options = $import->options;\n    $options['is_update_title'] = 0;    \n    $options['update_all_data'] = 'no';\n    $import->set(array(        \n        'options' => $options                \n    ))->update();            \n}\n\n\/\/ Recover import options after import completed.\nadd_action('pmxi_after_xml_import', 'wpai_pmxi_after_xml_import', 10, 2);\nfunction pmxi_pmxi_after_xml_import($import_id, $import) {\n  $options = $import->options;\n  $options['is_update_title'] = 1;    \n  $options['update_all_data'] = 'yes';\n    $import->set(array(        \n    'options' => $options                \n  ))->update();            \n}<\/code><\/pre><\/div>\n            <\/div>\n        <\/div>\n            <div class=\"docs-snippet\" style=\"position: relative;\"><a href=\"#export-yoast-seo-taxonomy-data\" class=\"snippet-icon-wrapper\"><img decoding=\"async\" src=\"https:\/\/www.wpallimport.com\/wp-content\/plugins\/dc-nav\/views\/..\/static\/icons\/doc-icon-developers.svg\" class=\"snippet-icon\"><\/a>\n            <a class=\"target\" id=\"export-yoast-seo-taxonomy-data\" style = \"position:absolute;\"><\/a>\n\n            <a href=\"#export-yoast-seo-taxonomy-data\" class=\"snippet-title\"><h2><strong>Export Yoast SEO Taxonomy Data<\/strong><\/h2><\/a>\n            <div class=\"snippet-content\">\n                \n<p>Since Yoast stores SEO data for taxonomies in the options database table, you'll need to retrieve the data using a custom PHP function (<a href=\"https:\/\/www.wpallimport.com\/documentation\/custom-wordpress-export-php\/\" target=\"_blank\" rel=\"noreferrer noopener\">see documentation<\/a>). Here is an example function:<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">function my_export_seo( $id, $field = '', $taxonomy = '' ) {\n\tif ( empty( $field ) ) return;\n\t\n\t$seo_data = get_option( 'wpseo_taxonomy_meta' );\n\tif ( empty( $seo_data ) ) return;\n\t\n\t$seo_data = maybe_unserialize( $seo_data );\n\t\n\tif ( ! array_key_exists( $taxonomy, $seo_data ) ) return;\n\t\n\tif ( array_key_exists( $id, $seo_data[ $taxonomy ] ) ) {\n\t\treturn $seo_data[ $taxonomy ][ $id ][ $field ];\n\t}\n}<\/code><\/pre><\/div>\n\n\n\n<p>This would be used in a <strong>Custom Export Field<\/strong> (<a href=\"https:\/\/www.wpallimport.com\/documentation\/custom-export-fields\/\" target=\"_blank\" rel=\"noreferrer noopener\">see documentation<\/a>) inside a <strong>Taxonomies<\/strong> export, and you'd pass the term ID, the SEO field you want, and the taxonomy name that you're exporting. Once this data is exported into a file, you can then import it into WordPress using our Yoast Import Add-On. Learn more about importing that data here: <a href=\"https:\/\/www.wpallimport.com\/documentation\/yoast-wordpress-seo\/\" target=\"_blank\" rel=\"noreferrer noopener\">Import to Yoast WordPress SEO<\/a>.<\/p>\n\n\n\n<p>Below are some examples of exporting WooCommerce Product Categories and their Yoast SEO data. You would call the code as shown in the screenshots.<\/p>\n\n\n\n<p>SEO Title:&nbsp;<\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[my_export_seo({Term ID},\"wpseo_title\",\"product_cat\")]<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example.png\" data-rel=\"lightbox-image-30\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"977\" height=\"1024\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example-977x1024.png\" alt=\"Export SEO title Example\" class=\"wp-image-10675975\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example-977x1024.png 977w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example-286x300.png 286w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example-768x805.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example-1466x1536.png 1466w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example-1955x2048.png 1955w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-title-Example.png 3528w\" sizes=\"(max-width: 977px) 100vw, 977px\" \/><\/a><\/figure>\n\n\n\n<p>SEO Description: <\/p>\n\n\n\n<div class=\"wp-block-wpcodebox-snippet wpcodebox-snippet\" data-language=\"php\"><pre class=\"line-numbers\"><code class=\"language-php\">[my_export_seo({Term ID},\"wpseo_desc\",\"product_cat\")]<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example.png\" data-rel=\"lightbox-image-31\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"986\" height=\"1024\" src=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example-986x1024.png\" alt=\"Export SEO Description Example\" class=\"wp-image-10676019\" srcset=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example-986x1024.png 986w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example-289x300.png 289w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example-768x798.png 768w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example-1479x1536.png 1479w, https:\/\/www.wpallimport.com\/wp-content\/uploads\/2024\/12\/Export-SEO-Description-Example.png 1756w\" sizes=\"(max-width: 986px) 100vw, 986px\" \/><\/a><\/figure>\n            <\/div>\n        <\/div>\n    <\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\">Related Docs<\/h2>\n\n\n\n\n\n<p>Explains how to run PHP functions in your import when using WP All Import.<\/p>\n\n\n\n\n\n<p>Learn about the different filters, hooks, and actions available in WP All Import and WP All Export.<\/p>\n\n\n\n\n\n<p>Shows you how to run PHP functions when exporting data with WP All Export.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.<\/p>\n","protected":false},"author":96198,"featured_media":0,"parent":2991545,"menu_order":2,"template":"","tags":[],"content_author":[213],"search_tags":[],"class_list":["post-2991646","documentation","type-documentation","status-publish","hentry","content_author-editorial-staff"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Example Code To Simplify Your Imports and Exports - WP All Import<\/title>\n<meta name=\"description\" content=\"This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Example Code To Simplify Your Imports and Exports - WP All Import\" \/>\n<meta property=\"og:description\" content=\"This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/\" \/>\n<meta property=\"og:site_name\" content=\"WP All Import\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/groups\/wpallimport\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-18T16:11:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2022\/05\/Main-WP-All-Import-Image.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data2\" content=\"Editorial Staff\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/\",\"url\":\"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/\",\"name\":\"Example Code To Simplify Your Imports and Exports - WP All Import\",\"isPartOf\":{\"@id\":\"https:\/\/www.wpallimport.com\/#website\"},\"datePublished\":\"2019-11-14T00:00:00+00:00\",\"dateModified\":\"2025-12-18T16:11:14+00:00\",\"description\":\"This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wpallimport.com\/#website\",\"url\":\"https:\/\/www.wpallimport.com\/\",\"name\":\"WP All Import\",\"description\":\"Import XML &amp; CSV to WordPress\",\"publisher\":{\"@id\":\"https:\/\/www.wpallimport.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wpallimport.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.wpallimport.com\/#organization\",\"name\":\"WP All Import\",\"url\":\"https:\/\/www.wpallimport.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wpallimport.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/logo-v5-no-text.svg\",\"contentUrl\":\"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/logo-v5-no-text.svg\",\"width\":199,\"height\":37,\"caption\":\"WP All Import\"},\"image\":{\"@id\":\"https:\/\/www.wpallimport.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Example Code To Simplify Your Imports and Exports - WP All Import","description":"This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/","og_locale":"en_US","og_type":"article","og_title":"Example Code To Simplify Your Imports and Exports - WP All Import","og_description":"This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.","og_url":"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/","og_site_name":"WP All Import","article_author":"https:\/\/www.facebook.com\/groups\/wpallimport","article_modified_time":"2025-12-18T16:11:14+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2022\/05\/Main-WP-All-Import-Image.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes","Written by":"Editorial Staff"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/","url":"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/","name":"Example Code To Simplify Your Imports and Exports - WP All Import","isPartOf":{"@id":"https:\/\/www.wpallimport.com\/#website"},"datePublished":"2019-11-14T00:00:00+00:00","dateModified":"2025-12-18T16:11:14+00:00","description":"This page provides different code examples available to use along with WP All Import, WP All Export and our different add-ons.","breadcrumb":{"@id":"https:\/\/www.wpallimport.com\/documentation\/code-snippets\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wpallimport.com\/documentation\/code-snippets\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.wpallimport.com\/#website","url":"https:\/\/www.wpallimport.com\/","name":"WP All Import","description":"Import XML &amp; CSV to WordPress","publisher":{"@id":"https:\/\/www.wpallimport.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wpallimport.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.wpallimport.com\/#organization","name":"WP All Import","url":"https:\/\/www.wpallimport.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wpallimport.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/logo-v5-no-text.svg","contentUrl":"https:\/\/www.wpallimport.com\/wp-content\/uploads\/2020\/02\/logo-v5-no-text.svg","width":199,"height":37,"caption":"WP All Import"},"image":{"@id":"https:\/\/www.wpallimport.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/documentation\/2991646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/documentation"}],"about":[{"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/types\/documentation"}],"author":[{"embeddable":true,"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/users\/96198"}],"version-history":[{"count":0,"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/documentation\/2991646\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/documentation\/2991545"}],"wp:attachment":[{"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/media?parent=2991646"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/tags?post=2991646"},{"taxonomy":"content_author","embeddable":true,"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/content_author?post=2991646"},{"taxonomy":"search_tags","embeddable":true,"href":"https:\/\/www.wpallimport.com\/wp-json\/wp\/v2\/search_tags?post=2991646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}