Skip to content

Instantly share code, notes, and snippets.

@accrane
Created May 11, 2016 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save accrane/e3d95c1bbc675003e65d24a1f939a286 to your computer and use it in GitHub Desktop.
Save accrane/e3d95c1bbc675003e65d24a1f939a286 to your computer and use it in GitHub Desktop.
<?php
// Get RSS Feed(s)
include_once( ABSPATH . WPINC . '/feed.php' );
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( 'http://journeysfromayrden.tumblr.com/rss' );
if ( ! is_wp_error( $rss ) ) : // Checks that the object is created correctly
// Figure out how many total items there are, but limit it to 5.
$maxitems = $rss->get_item_quantity( 5 );
// Build an array of all the items, starting with element 0 (first element).
$rss_items = $rss->get_items( 0, $maxitems );
endif;
// If none
if ( $maxitems == 0 ) : ?>
<li>
<?php _e( 'No items', 'my-text-domain' ); ?>
</li>
<?php
else :
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<article class="tumblr-article">
<h2><?php echo $item->get_title() ?></h2>
<p><?php echo $item->get_content() ; ?></p>
<div class='tumblr-link'>
<a href="<?php echo esc_url( $item->get_permalink() ); ?>">See Tumblr Article</a>
</div><!-- tumblr link -->
</article>
<?php
endforeach;
endif;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment