Support » Plugins and Hacks » WP All Import – create multiple file path with [FOREACH]

  • Resolved Schmalitz

    (@schmalitz)


    I need to solve following obstacle to create variable file-path:

    The FOREACH shortcode returns a specific XML-field like this:

    [FOREACH({Filename})]
    {.}
    [ENDFOREACH]<br>

    Resulting in

    Filename 1
    Filename 2
    Filename 3
    etc.

    That’s fine but I need to do this:

    fix/{CAT[1]}/Filename 1
    fix/{CAT[1]}/Filename 2
    fix/{CAT[1]}/Filename 3
    etc.

    …where {CAT[1]} is a variable output of the XML.

    Any ideas?

    Thank you very much for your help in advance!

Viewing 1 replies (of 1 total)
  • I also asked the official support (Soflyy) the same question and got the answer.

    Code for the functions.php:

    global $upc;
    
    function set_upc($local_upc){
    global $upc;
    $upc = $local_upc;
    }
    
    function myfunc($files){
    global $upc;
    return $upc . '/' . $files;
    }

    Code for the import template:

    [set_upc({UPC[1]})]
    [FOREACH({Tracks[1]/Track})]
    <a href=>[myfunc({AudioFiles[1]/AudioFile[1]/Filename[1]})]
    [ENDFOREACH]

    Now its very easy to play around with the tempalte code to change the anchor text, structur etc.

    Thanks to Soflyy! Excellent support!

Viewing 1 replies (of 1 total)
  • The topic ‘WP All Import – create multiple file path with [FOREACH]’ is closed to new replies.