Results 1 to 4 of 4

Thread: wordpress plugin to display recent posts

  1. #1
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055

    wordpress plugin to display recent posts

    There are vbulletin plugins/hacks to display the recent forum posts on a non vb page, such as this site's homepage.

    I'm looking for the same thing for wordpress. In my searches I'm just finding wordpress plugins to change your wordpress homepage. I'm looking for something to add automatically to a non-wordpress page.

    I could code it myself from the database. Or I could code an RSS parser to take it from my own RSS feed, but this has to be already coded somewhere. Anyone know?
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  2. #2
    Not that blue at all Blue Cat Buxton's Avatar
    Join Date
    May 2004
    Location
    UK
    Posts
    932
    I looked for this a while back and don't think it exists.

    In the end I used the RSS option, which works well enough for me.

    This is the code I used, with credit shown for the orignal author:


    PHP Code:

    <?php

    /*##############################################

    RSS parser written for bMachine feed.
    This script can be used to read ANY kind of RSS feeds from anywhere!


    *--------------------------------------------*
    Written by Kailash Nadh,
    http://bnsoft.net , kailash@bnsoft.net

    Author of bMachine, http://boastology.com

    I wrote this script on the 1st day I studied
    XML by running through the documentation at www.php.net ;)
    *--------------------------------------------*

    WARNING!: This script is Heavily commented! :)


    This is how the script works.
    > Reads the XML file
    > Parses it into an array using xml_parse_into_struct()
    > Converts that array into a more sensible, easily usable array
        [ See the structure.txt file to get an idea of the array structure ]
    > Finally, Display the data in anyway you want!

    This script demonstrates the use of simple logic
    to do Complex XML/RSS parsing functions
    This script can be easily developed into a powerful application.

    ##############################################*/

    global $data;


        
    // Enter the url to an RSS feed
    $url="http://news.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml";

    $file $url;
    $ch curl_init($file);
    $fp = @fopen("temp.xml""w");
    curl_setopt($chCURLOPT_FILE$fp);
    curl_setopt($chCURLOPT_HEADER0);
    curl_exec($ch);
    curl_close($ch);
    fclose($fp);
    $file "temp.xml";
    //$fp = fopen($file, "r");
    //$data = fread($fp, 1000);




    $data=@fread(fopen($file,"r"),10000) or die("Cant open $url!");

    // Get the file contents

    $myar=getXmlData($data);
        
    // What ever it may be, the argument to this
        // function should be the XML document's content


    // Now $myar holds the fully parsed XML contents.
    // It may have a number of tags, like <TITLE> , <LINK> , <AUTHOR> , <SOMETHING> ... and so on
    // With a simple loop, you can extract all the tags and their values neatly

    // Remember, $i<= should be lesser than or equal to the number of values
    // a tag has. If you give count($myar), it will only take the number of tags.
    // See structure.txt for better understanding.


    for($i=0;$i<=count($myar[TITLE]);$i++) {

    // Here, we want to read the TITLE, DESCRIPTION, and LINK of the RSS feed.
    // You can read the values of any tag like this.
    // $myar[TITLE][$i], $myar[SOMETHING][$i], $myar[SOMETAG][$i].... and so on..
    // Here it goes

    $title=$myar[TITLE][$i+1];
    $text=$myar[DESCRIPTION][$i];
    $link=$myar[LINK][$i+1];

        if(
    $title) {
        if (
    $i>=and $i<3)
        {
    echo <<<EOF
    <a href="$link"><font size="2" face="Verdana" color="blue">$title</font></a><br>
    <font size="2" face="Verdana">
    $text</font><br><br>
    <hr width="100%" size="1" align="left">
    EOF;
    }
        }

    }



    //#####################################################################

    // This is the function. It returns the array of the parsed XML data

    function getXmlData($xml_doc) {

    //echo "xml_doc is ";
    //echo $xml_doc;    

    $n=0;          // Counter used for arraying the XML data
    $ar=array(); // The main array for storing parsed xml using xml_parse_into_struct()

    // Parse the XML document

    $parser xml_parser_create();
    //$simple = "<para><note>simple note</note></para>";
    $simple=$xml_doc;
    //echo $simple;

    xml_parse_into_struct($parser,$simple,$vals,$index);
    // or die(xml_error_string(xml_get_error_code($parser)));
    xml_parser_free($parser);


    $ttags=array(); // Temporary arry for storing tag names


    // The main part. This is MY CREATION
    // and this piece of code makes this script simple :)
    // This is the "MAGIC LOOP" !! :)

    for($n=0;$n<=count($vals)-1;$n++) {
        if(
    trim($vals[$n][value])) {
        
    $ar[$vals[$n][tag]][count($ar[$vals[$n][tag]])]=$vals[$n][value];
        
    $ttags[$vals[$n][tag]]=$vals[$n][tag];
        }
    }


    // Array for storing all the tag names
    // This array will hold all the Tag names found in the XML document
    // eg: ("TITLE","LINK","AUTHOR","DOMAIN")..
    // Use this if you need it.

    $tags=array();

    // Extract and save the tag names to the array
    foreach($ttags as $tagi) { array_push($tags,$tagi); }

    return 
    $ar;

    }

    ?>

  3. #3
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    Nifty, thanks.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  4. #4
    Registered
    Join Date
    Mar 2004
    Location
    Philadelphia, PA
    Posts
    106
    Have you taken a look at FeedBurner? In addition to giving you all kinds of information about the circulation and usage of your feed, they have tons of tools for working with the feed, from automatically converting it into every reader's preferred format (RSS 1/2/ATOM), showing it in HTML format when viewed through a browser, to a bit of JavaScript to syndicate the feed as HTML (like you're looking for) called BuzzBoost.
    I'm Dan. This is my blog. I give you... free web stats.

Similar Threads

  1. Gallery plugin for WordPress
    By fredarn in forum Graphics & Multimedia
    Replies: 5
    Last Post: 07-12-2006, 11:38 AM
  2. WordPress Spam Plugin
    By tonyjk3 in forum Website Programming & Databases
    Replies: 0
    Last Post: 04-04-2006, 05:09 PM
  3. Wordpress plugin
    By Masetek in forum HTML, CSS, Layout, and Design
    Replies: 17
    Last Post: 03-12-2006, 06:46 PM
  4. Recent forum posts feature
    By mirdin in forum HTML, CSS, Layout, and Design
    Replies: 3
    Last Post: 04-10-2004, 01:51 PM
  5. Recent posts
    By walt in forum Site and Forum Feedback
    Replies: 2
    Last Post: 08-23-2003, 05:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •