Advertisement
ridgey28

SimplePie-WP-Filter Single Post by WP ID

Jun 4th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.48 KB | None | 0 0
  1. <?php
  2. /*
  3.   SimplePie Wordpress - Display 1 post by filtering it's ID
  4.   [link]http://www.worldoweb.co.uk/2012/display-wordpress-posts-on-another-wp-blog
  5. */
  6. ?>
  7. <ul class="rss-items" id="wow-feed">
  8. <?php
  9. if ($maxitems == 0){
  10.     echo '<li>No items.</li>';
  11. }
  12. else {
  13.     foreach ($rss_items as $item):
  14.         $id = $item->get_id(); //Get's IDs of posts
  15.         //echo var_dump($id)  Uncomment, save and reload to display ID's
  16.    
  17.         //Replace below with your ID
  18.         if ($id === 'http://www.worldoweb.co.uk/?p=5941') {?>
  19.            
  20.         <li class="item">
  21.             <span class="rss-image">
  22.               <?php echo '<img src="' . get_first_image_url($item->get_content()) . '"/>';?>
  23.             </span>
  24.             <span class="data">
  25.               <h5>
  26.                 <a href='<?php echo esc_url($item->get_permalink());?>'
  27.                 title='<?php echo esc_html($item->get_title());?>'>
  28.                     <?php echo esc_html($item->get_title());?></a>
  29.               </h5>
  30.             <span class="date-image">&nbsp;</span>
  31.                 <small><?php echo $item->get_date('F Y');?></small>
  32.                 <span class="comment-image">&nbsp;</span>
  33.                 <small><?php $comments = $item->                                   
  34.                         get_item_tags('http://purl.org/rss/1.0/modules/slash/', 'comments');?>
  35.                     <?php $number = $comments[0]['data'];?>
  36.                     <?php if ($number == '1') {
  37.                             echo $number . "&nbsp;" . "Comment";}
  38.                             else {
  39.                             echo $number . "&nbsp;" . "Comments";}?>
  40.                 </small>
  41.                 <p><?php echo $item->get_description();?></p>
  42.             </span>
  43.         </li>
  44.         <?php } //end if?>
  45.         <?php endforeach;?>
  46.         <?php } //end if;?>
  47. </ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement