Variable Number Of Images Per Host

Variable Number Of Images Per Host

Sometimes, each record in your XML or CSV file will have a different number of images associated with it. Here are some of the most common ways to handle this scenario with WP All Import.

Option A: Image URLs Are Stored In A Single Column Or Element, And Separated By A Character

Simply drag & drop the column or element containing your image URLs or filenames to the appropriate textbox, and enter in the appropriate Separator character if it is different than a comma.

Drag and drop single element

Option B: Image URLs are Contained In Different CSV Columns or XML Elements

WP All Import will ignore any blank image URLs, so you can simply specify all possible XPaths that could potentially point to image URLs for certain records. Any that don』t point to image URLs for the current record will be ignored for that record.

1. Go to the record in your XML or CSV file has the most images in the XML/CSV tree on the right, by entering in the record number and then clicking anywhere on the XML/CSV tree:

XML Tree View

2. Drag & drop all the elements or columns containing image URLs into the image URLs box.

Multiple image elements

Although you can』t see it in the screenshot, in our example, record 179 has 9 different images.

No other records have 9 different images, they have between 1 and 8. WP All Import will simply ignore {image_9[1]} when it doesn』t exist, {image_8[1]} when it doesn』t exist, etc.

Option C: Use an XPath query or a FOREACH Loop

If all your image URLs are stored as child elements of some parent element, you can use a FOREACH loop to loop through each child element.

This is only applicable to XML files.

Example XML:

Featured Image
Second Image
Third Image
Fourth Image

You can use this XPath query to output a comma delimited list of the image names:

{images/image/@src}

Or, if you need to prepend a URL, or add something else to the data, you can use a FOREACH loop instead:

[FOREACH({images/image})]http://www.example.com/my-folder/{@src},[ENDFOREACH]

More information on FOREACH loops.

Meta Data

Meta Data

WP All Import can import image meta data from your file to WordPress. The possible meta fields are Title, Caption, Alt Text, and Description – as shown in the image below.

Image Meta Data Edit View

Image meta data can be imported in the SEO & Advanced Options sub-section of the Images section in WP All Import.

Meta data will be associated with images based on the order of the images and order of the meta data – for example, the first caption will be associated with the first image, the second caption will be associated with the second image, and so on.

Image Meta Data