View Full Version : Wordpress, RSS and php
Simon
May 27th, 2006, 21:55
OK,
Long and short of it:
I am using Wordpress for a blog on domain.com/blog
I want to use php to include the headlines of the last X number of blog entries on domain.com
I have spent three hours browsing wordpress.org's documentation and can find not even one bit of information on how to do this (it doesn't help that their search function is as useful as a chocolate fireguard).
Does anyone have any idea how to do this?
Simon
Martin
May 27th, 2006, 22:08
Would this do what you want?
http://codex.wordpress.org/Creating_a_Static_Front_Page
Simon
May 27th, 2006, 22:16
Thanks, Martin.
I am not sure if that's what I need or not but I think it's something I can work from. Most specifically, the mini-loop feature looks workable.
I am very surprised Wordpress doesn't mirror some other blogs and have java or php snippets for this.
Simon
crazyfish
May 29th, 2006, 14:47
This might help http://wordpress.org/support/topic/47572 looks like it might need some tweaking.
You might be able to find something here http://wp-plugins.net/
Simon
May 29th, 2006, 15:34
Thanks, Nick. I'll toy around with that solution too and see which has the better output. I did try one thing myself which I hought would work but I needed the links to open in a new window and can't get them to do that (www.eirca.net/test.php) so I am going to revert back to the text based and see what happens :)
Simon
ethicaldesign
May 29th, 2006, 19:22
I'm pretty new to wordpress (just started using it for something I'm doing infact), but couldn't you use the rss feeds that it generates for this?
That would allow you to place the latest posts with links on a page on your site outside the blog altogether, and even on completely seperate sites on a different server.
There are a few php scripts out there I think that would let you do this quite easily, or it shouldn't be too hard to write one to parse the xml. If you do a google search for:
"rss to html" or "display rss feed php" then you should find some examples I think and there's likely already some code out there that you could use or tweak to do what you want.
ethicaldesign
May 29th, 2006, 19:26
Just did a quick search and came up with this:
http://www.feedforall.com/free-php-script.htm
Which looks like it might do the trick, though if you search some more there should be others out there I expect (or perhaps a php function or class you can use in your own scripts).
Simon
May 29th, 2006, 21:07
Thanks, all of you :)
Between the many suggestions I managed to take an element from three or four of them and get this up and running.
Let me know what you think: http://www.eirca.net/ (left menu under "countdown to daytona"
Simon
crazyfish
May 29th, 2006, 23:00
Looks good Simon. Do you want to share your code? :)
Simon
May 30th, 2006, 00:04
Looks good Simon. Do you want to share your code? :)
I can try. For the last part I handed it over to someone else so I didn't wreck the page.
Here it is:
Download and configure rss2html (http://www.feedforall.com/free-php-script.htm)
Take elements out that aren't usable in a navigation panel (for instance, the script tries to take a large chunk of your description).
Calling the script:
<?php include('http://www.domain.com/path/to/rss2html.php?XMLFILE=http://www.domain.com/path/to/feed/&TEMPLATE=http://www.domain.com/path/to/parsetemplate.html&MAXITEMS=5'); ?>
I am told that when calling that the first time, the changes you need to make to wordpress RSS/ XML files are "obvious" (They weren't obvious to me though).
To get the result as displayed on our website, here's the code:
In the parse template file:
~~~BeginItemsRecord~~~
<li class="style5"><A href="~~~ItemLink~~~" target="_blank">~~~ItemTitle~~~</A> ~~~EndItemsRecord~~~</li>
The rest depends on where you're calling the file. Ours is integrated in to an existing table so it would be very different to anyone elses.
Simon
vBulletin® v3.6.8, Copyright ©2000-2012, Jelsoft Enterprises Ltd.