Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php ///Start of SimplePie
- //Add your feeds here
- $rsslist = array( 'http://www.worldoweb.co.uk/feed',
- 'http://www.alfiemilne.org.uk/news/feed');
- $rss = fetch_feed($rsslist);
- if (!is_wp_error($rss)) :
- $maxitems = $rss -> get_item_quantity(10);//change item quantity if needed
- $rss_items = $rss -> get_items(0, $maxitems);
- endif;
- ?>
- /*The below function strips the first image from the feed. May or may not be useful*/
- <?php
- function get_first_image_url($html) {
- if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) {
- return $matches[1];
- }
- }?>
- <ul class="rss-items" id="wow-feed">
- <?php
- if ($maxitems == 0){
- echo '<li>No items.</li>';
- }
- else {
- foreach ($rss_items as $item):
- $id = $item->get_id(); //Get's IDs of posts
- //echo var_dump($id);// Uncomment, save and reload browser to display ID's
- //Replace below with your ID's, can be from different blogs etc
- $id_list = array('http://www.worldoweb.co.uk/?p=5787','http://www.worldoweb.co.uk/?p=5941','http://www.worldoweb.co.uk/?p=5807','http://www.alfiemilne.org.uk/news/?p=1225');
- if (array_keys($id_list,$id)) {?>
- <li class="item">
- <span class="rss-image">
- <?php echo '<img src="' . get_first_image_url($item->get_content()) . '"/>';?>
- </span>
- <span class="data">
- <h5>
- <a href='<?php echo esc_url($item->get_permalink());?>'
- title='<?php echo esc_html($item->get_title());?>'>
- <?php echo esc_html($item->get_title());?></a>
- </h5>
- <span class="date-image"> </span>
- <small><?php echo $item->get_date('F Y');?></small>
- <span class="comment-image"> </span>
- <small><?php $comments = $item->
- get_item_tags('http://purl.org/rss/1.0/modules/slash/', 'comments');?>
- <?php $number = $comments[0]['data'];?>
- <?php if ($number == '1') {
- echo $number . " " . "Comment";}
- else {
- echo $number . " " . "Comments";}?>
- </small>
- <p><?php echo $item->get_description();?></p>
- </span>
- </li>
- <?php } //end if?>
- <?php endforeach;?>
- <?php } //end if;?>
- </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement