I'm a WordPress beginner so please bear with me. I'm currently using WP All Import to import my data, and there are a few images are stored as child elements of some parent element.
Following are the screen shot of the XML which exported from phpMyAdmin. The structure is different from what I see from WP All Import youtube tutorial. I'm not sure whether this is correct but the data can imported successfully.
From the screen shot (please take note on red boxes), I have same information with different id and images. My question is can I use the Foreach loop for my case? And how to write the Foreach loop based on my case?
This is the code I took from WP All Import website. But I cannot follow exactly same as my XML has different structure.
Example XML:
<images>
<image src=”image1.jpg” alt=”i am first image”>Featured Image</image>
<image src=”image2.jpg” alt=”this is image2″>Second Image</image>
<image src=”image3.jpg” alt=”this is image3″>Third Image</image>
<image src=”image4.jpg” alt=”this is image4″>Fourth Image</image>
</images>
Use the following FOREACH loop:
[FOREACH({images/image})]
http://www.example.com/my-folder/{@src},
[ENDFOREACH]
I solved it by using SQL
GROUP CONCAT
to combine all the images into same id.So this is the result:
The I used FOREACH loop to read all the images.