Access a custom field from and RSS feed in WordPress

I am trying to access a custom field from an RSS feed in WordPress (using SimplePie), but I am not able to

// get HCBC feed
$media_rss = fetch_feed('feed.theplatform.com/f/IfSiAC/VfW_gmOIG_yI');

if(!is_wp_error($media_rss)) {
     // get limit of 5 items
     $max_items = $media_rss->get_item_quantity(5);

     // add items to indexed array starting at 0
     $rss_items = $media_rss->get_items(0, $max_items);
}

foreach($rss_items as $item) {
    $public_url = $item->get_item_tags('plmedia', 'publicUrl');
    print_r($public_url);
}

you can see in the RSS that the namespace and tag are there, but for some reason $public_url is always empty. I’m not sure what I am doing wrong.

Related posts

1 comment

  1. Turns out I didn’t understand what the namespace was supposed to be. The following is correct:

    foreach($rss_items as $item) {
        $public_url = $item->get_item_tags('http://xml.theplatform.com/media/data/Media', 'publicUrl');
        print_r($public_url);
    }
    

Comments are closed.