943,914 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 392
  • PHP RSS
Jun 3rd, 2009
0

Wordpress question

Expand Post »
I am designing a website for someone at the moment and they want a preview of thier wordpress blog on thier home page(not blog home page)

Is there a good way to do this automatically so that it updates itself whenever a new blog is posted or will it be a lot easier to just do it manually?

I have a completly free reign over what languages and how the home page will be coded.

Any help greatly appreciated.
Last edited by kained; Jun 3rd, 2009 at 11:11 am.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
kained is offline Offline
126 posts
since May 2004
Jun 3rd, 2009
0

Re: Wordpress question

just parse the xml from the rss feed...

php Syntax (Toggle Plain Text)
  1. <?PHP
  2.  
  3. /******************************************************************************************************************
  4. RSS PARSING FUNCTION
  5. ******************************************************************************************************************/
  6.  
  7. //FUNCTION TO PARSE RSS IN PHP 4 OR PHP 4
  8. function parseRSS($url) {
  9.  
  10. //PARSE RSS FEED
  11. $feedeed = implode('', file($url));
  12. $parser = xml_parser_create();
  13. xml_parse_into_struct($parser, $feedeed, $valueals, $index);
  14. xml_parser_free($parser);
  15.  
  16. //CONSTRUCT ARRAY
  17. foreach($valueals as $keyey => $valueal){
  18. if($valueal['type'] != 'cdata') {
  19. $item[$keyey] = $valueal;
  20. }
  21. }
  22.  
  23. $i = 0;
  24.  
  25. foreach($item as $key => $value){
  26.  
  27. if($value['type'] == 'open') {
  28.  
  29. $i++;
  30. $itemame[$i] = $value['tag'];
  31.  
  32. } elseif($value['type'] == 'close') {
  33.  
  34. $feed = $values[$i];
  35. $item = $itemame[$i];
  36. $i--;
  37.  
  38. if(count($values[$i])>1){
  39. $values[$i][$item][] = $feed;
  40. } else {
  41. $values[$i][$item] = $feed;
  42. }
  43.  
  44. } else {
  45. $values[$i][$value['tag']] = $value['value'];
  46. }
  47. }
  48.  
  49. //RETURN ARRAY VALUES
  50. return $values[0];
  51. }
  52.  
  53.  
  54. /******************************************************************************************************************
  55. SAMPLE USAGE OF FUNCTION
  56. ******************************************************************************************************************/
  57.  
  58. //PARSE THE RSS FEED INTO ARRAY
  59. $xml = parseRSS("http://worldthreat.net/?feed=rss2");
  60.  
  61. //SAMPLE USAGE OF
  62. foreach($xml['RSS']['CHANNEL']['ITEM'] as $item) {
  63. echo("<p class=\"indexBoxNews\"><a href=\"{$item['LINK']}\" target=\"_blank\" class=\"indexBoxNews\">{$item['TITLE']}{$link}</a></p>");
  64. }
  65.  
  66. ?>
Last edited by peter_budo; Jun 3rd, 2009 at 1:35 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
worldthreat is offline Offline
3 posts
since Jun 2009
Jun 3rd, 2009
0

Re: Wordpress question

Wordpress preview lugins at wordpress.com
Wordpress latest posts plugins at wordpress.com
a bunch of other plugins from various other providers
hav no experience as which ones work best,
Reputation Points: 562
Solved Threads: 368
Posting Maven
almostbob is offline Offline
2,970 posts
since Jan 2009
Jun 3rd, 2009
0

Re: Wordpress question

thats amazing work world threat.

With that php script its literlly dump the whoe thing in the div i want i to appear in and change

PHP Syntax (Toggle Plain Text)
  1. //PARSE THE RSS FEED INTO ARRAY
  2. $xml = parseRSS("http://worldthreat.net/?feed=rss2");

to reflect the actually addres of the rss feed in the blog?

Or do

PHP Syntax (Toggle Plain Text)
  1. 'RSS']['CHANNEL']['ITEM']

all need defining somehow as well.
Last edited by kained; Jun 3rd, 2009 at 1:49 pm.
Reputation Points: 10
Solved Threads: 0
Junior Poster
kained is offline Offline
126 posts
since May 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: help i can draw it but i cant php it!!!
Next Thread in PHP Forum Timeline: php freelancing





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC