Support

Account

Home Forums General Issues Populate XML file with ACF custom field data Reply To: Populate XML file with ACF custom field data

  • Thanks Hazard that was closest to the solution.
    I created an archive-custom-pt.php and used $title= get_field('title'); to populate the XML document.

    Sample idea

    
    $doc = new DOMDocument('1.0','UTF-8');
    $doc->formatOutput = true; 
    $doc->preserveWhiteSpace = false;
    
    $root = $doc->createElement('Book');
    $root = $doc->appendChild($root);
    
    // Title
    $title = $doc->createElement('title');
    $title = $root->appendChild($title);
    
    $doc->save("books.xml");
    

    The only issue i have now is it will write the post custom field data to the books.xml but only a single post and not all the posts.

    Thank you for your help!