Home Forums General Issues Displaying ACF Field in a URL?


Displaying ACF Field in a URL?

  • Hello,

    Hoping someone is able to help.
    I have some PHP embed code (see below) which I need to customize depending on page.
    Therefore I’ve created a ACF text field and associated this to the page/post type I require.

    I’ve managed to post content using ACF before but cannot figure out how to add text to a URL field.

    Example: My field name is “elite_prospects_id” and I need to place this at the end of the URL.

    $rss = new SimpleXMLElement('$_elite_prospects_id’, null, true);
    foreach($rss->xpath('channel/item') as $item)
      echo  utf8_decode($item->description);

    Would appreciate any help!

  • If the above code is inside a post loop then something like

    $rss = new SimpleXMLElement(''.get_field('_elite_prospects_id'), null, true);

    If it’s not in a loop then you’ll need to supply the post_id the get_field() call.

  • Thank you John! 🙂 This was perfect and exactly what I needed!

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

The topic ‘Displaying ACF Field in a URL?’ is closed to new replies.