Support

Account

Home Forums General Issues Getting ACF to work with XML

Solved

Getting ACF to work with XML

  • Hi there,

    I’ve purchased the ACF plugin and all its add ons for about 2 years, and really love it! I’d like to try out something new, and need help doing it as i’m not very literate with php or xml.

    I need to grab XML data from a feed, with a portion of the URL being determined by an ACF field, i.e. <?php the_field(‘career_listing_url’, ‘option’); ?>.

    Something like this (pardon my garbage code)

    <?php
    $jobs = simplexml_load_file('http://domain.com/jobrss.aspx?jobspecialization=<?php the_field('acf_field', 'option'); ?>');
    foreach ($jobs->channel->item as $jobinfo) { ?>
    <li></li>
    <?php } ?>
    

    How should I write the code properly so that it works?
    Can anyone help? THANK YOU!

  • It’s okay~ I’ve figured out the solution.

    <?php
    $xml = 'http://domain.com/jobrss.aspx?jobspecialization='.get_field('acf_field', 'option');
    $jobs = simplexml_load_file($xml);
    foreach ($jobs->channel->item as $jobinfo) { ?>
    <li></li>
    <?php } ?>

    Cheers

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Getting ACF to work with XML’ is closed to new replies.