Posted By

ryarwood on 07/30/10


Tagged

php rss feed wordpress news


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

osirisinternet
manavecplan
booski


Wordpress news feed using MagpieRSS


 / Published in: PHP
 

URL: http://www.pacificshoreshb.com

  1. <? require_once('/home/p11creative/www/pacific.p11.com/magpierss/rss_fetch.inc'); ?>
  2.  
  3. <?php
  4. define("MAGPIE_OUTPUT_ENCODING", "UTF-8");
  5. $url = "http://www.pacificshoreshb.com/news/?feed=atom";
  6. $rss = fetch_rss($url);
  7. $item = $rss->items[0];
  8.  
  9. $postTitle = $item['title'];
  10. $postContent = $item['summary'];
  11.  
  12. $postDate = date('F j, Y', strtotime($item['published']));
  13. $linkTitle = $item['link'];
  14. echo "<h2>Community News</h2>";
  15. echo "<h4>$postDate</h4>";
  16. echo "<h3>$postTitle</h3>";
  17.  
  18. $no_of_words = 24;
  19. $str_array = split(" ",$postContent,$no_of_words+1);
  20. if(count($str_array)>$no_of_words) {
  21. print "<p>";
  22. for($i=0; $i < $no_of_words; $i++) {
  23. print " ".$str_array[$i];
  24. }
  25. print "... <a href=\"http://www.pacificshoreshb.com/news/\" class=\"tenner\">MORE &gt;</a></p>";
  26. } else {
  27. print "<p>";
  28. for($i=0; $i < $no_of_words; $i++) {
  29. print " ".$str_array[$i];
  30. }
  31. print " <a href=\"http://www.pacificshoreshb.com/news/\" class=\"tenner\">MORE &gt;</a></p>";
  32. }
  33. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: batfan on July 30, 2010

Neat but, I think you mean MagpieRSS (rather than MagieRSS)

Posted By: ryarwood on July 31, 2010

Right you are Batfan. Changed it.

You need to login to post a comment.