Created
January 30, 2013 11:55
-
-
Save krzysu/4672824 to your computer and use it in GitHub Desktop.
Wordpress: display N posts on static page from RSS source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rss = fetch_feed( 'http://www.ondango-labs.com/feed/' ); | |
if (!is_wp_error( $rss ) ) : | |
$maxitems = $rss->get_item_quantity(5); | |
$rss_items = $rss->get_items(0, $maxitems); | |
?> | |
<div class="three-from-four" id="latest-posts-box"> | |
<?php foreach($rss_items as $index => $item): ?> | |
<article class="one-from-two element <?= ($index % 2 == 1) ? 'last' : '' ?>"> | |
<h2> | |
<a href="<?php echo esc_url( $item->get_permalink() ); ?>" title="<?php echo $item->get_title(); ?>"> | |
<?php echo $item->get_title(); ?> | |
</a> | |
</h2> | |
<div class="element-body"> | |
<?php echo $item->get_description(); ?> | |
</div> | |
</article> | |
<?php endforeach; ?> | |
</div> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment