5

Analysis with SimplePie in Wordpress (get_item_tags)

 2 years ago
source link: https://www.codesd.com/item/analysis-with-simplepie-in-wordpress-get-item-tags.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Analysis with SimplePie in Wordpress (get_item_tags)

advertisements

I have triying to parse some specific elements from a xml feed in my Wordpress using SimplePie and "get_items_tags" to fix namespaces (I wanna print the content, no attributes). At the end nothing is displayed, just empty "p" tags. I have been searching, but no idea of what I can be doing wrong, any help,please? Please check the code:

 <?php if(function_exists('fetch_feed')) {
    include_once(ABSPATH . WPINC . '/feed.php' );
    $feed = fetch_feed( 'http://servizos.meteogalicia.es/rss/predicion/rssLocalidades.action?idZona=32054&dia=0&request_locale=gl');
    $maxitems = $feed->get_item_quantity(25);
     $rss_items = $feed->get_items(0, $maxitems);}
     if ($maxitems == 0)
    echo  "<p>Nadena</p>";
    else foreach ( $rss_items as $item ) : ?>
        <p><?php echo $item->get_item_tags("http://purl.org/dc/elements/1.1/","tMax"); ?></p>
    <p><?php echo $item->get_item_tags("http://purl.org/dc/elements/1.1/","tMin"); ?></p>

    <?php  endforeach; ?>


I needed to get the content of tag "thumbnail" and this worked for me:

$thumbnail = $item->get_item_tags('', 'thumbnail');
echo $thumbnail[0]["data"];


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK