1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to show recent wordpress posts on my html site?

Discussion in 'WordPress' started by seodelhi, Jan 16, 2011.

  1. #1
    I have a static html site, under which I have installed a wordpress blog which is running at myhtmlsite.com/blog/, what i want is a way to show recent posts in my wordpress blog on my html site. If anybody know a way to do this, please let me know.
     
    seodelhi, Jan 16, 2011 IP
  2. jezzz

    jezzz Notable Member

    Messages:
    4,884
    Likes Received:
    190
    Best Answers:
    0
    Trophy Points:
    200
    #2
    You have to convert that Static Page extension to PHP! because HTML extension doesn't support any PHP Function unless the file extension is transformed in to .php
     
    jezzz, Jan 16, 2011 IP
  3. seodelhi

    seodelhi Active Member

    Messages:
    882
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    70
    #3
    Are not there any scripts/plugin for this purpose?
     
    seodelhi, Jan 16, 2011 IP
  4. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You do not need a plugin. All you need to do is make the server think that the .html (or .htm ) is a Php script. By default, the server does not load up the Php interpreter to run scripts.

    I did something similar back in the day when Blogger had FTP capability. Blogger would store the posts as Html onto your server.


    Edit your .htaccess file and add the following up at the very top. Do not edit anything else in this file.

    AddType application/x-httpd-php .html .htm
    Code (markup):
    To test that it is working, add this to the top of the BODY in one of your .html files:

    <?php echo "PHP is fun!!!"; ?>
    Code (markup):
    That echoes a string to the screen if everything is okay.


    Here is the trick though, you need to access the WordPress database to get a list of recent posts, or simpler method of using just the blog feed. Using the WP database would give you other stuff to integrate into the static pages, but lets keep this simple.

    Use the Php function class SimplePie to parse the feed. This will allow you to wrap the feed elements with Html as you see fit. All you need to do is wrap your code inside of the opening and closing script tags for php and the server will run it.

    SimplePie is usually available to use with Php. If it is not, you can include WordPress' version before using it.
     
    Dodger, Jan 16, 2011 IP
  5. asdirc

    asdirc Active Member

    Messages:
    275
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Change the extension of your page (home page or page where you want to put the recent comments), define in it's header the mysql info (DB, user, pass) and get the wp code that shows you last posts. If you need help you can contact me via pm.
     
    asdirc, Jan 17, 2011 IP
  6. Dodger

    Dodger Peon

    Messages:
    1,494
    Likes Received:
    60
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I would advise against this. Especially if you do not know what you are doing. Once you go down the road of working with the WordPress database outside of its own system you run the risk of opening it up to exploit.
     
    Dodger, Jan 17, 2011 IP