/ Published in: PHP

Thanks Dan Gayle.
http://www.dangayle.com/import-feeds-wordpress-fetch-feed/
http://www.dangayle.com/import-feeds-wordpress-fetch-feed/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php include_once(ABSPATH . WPINC . '/rss.php'); $feed = 'http://dangayle.com/feed/'; $rss = fetch_feed($feed); if (!is_wp_error( $rss ) ) : $maxitems = $rss->get_item_quantity(3); $rss_items = $rss->get_items(0, $maxitems); if ($rss_items): echo "<ul>\n"; foreach ( $rss_items as $item ) : //instead of a bunch of string concatenation or echoes, I prefer the terseness of printf //(http://php.net/manual/en/function.printf.php) printf('<li><a href="%s">%s</a><p>%s</p></li>',$item->get_permalink(),$item->get_title(),$item->get_description() ); endforeach; echo "</ul>\n"; endif; endif; ?>
URL: http://www.dangayle.com/import-feeds-wordpress-fetch-feed/
Comments
