February 12, 2013 Alex

WordPress Help + Include Latest Posts HTML Code on a PHP Static Site

As WordPress blogs become more popular, the need for a static sites and wordpress to interact is more important than ever. I hunted the internet for a few minutes and decided to write this post because it was hard to find any solution. I was able to finally find the solution on how to include the latest post onto my static html website. It’s a two part process and it is simple as long as your wordpress blog is on the same website FTP so you can include files from other directories on your main site. If you understand an include statement or even copy and paste then you should be fine.

Just put this code snippet in wherever you want the top 10 listings to show on your website. Have an area dedicated for it. Usually a table cellor a

that can grow longer or shrink will work fine.

<div>
<?
include('./blog/wp-load.php');
get_archives('postbypost', '10', 'custom', '<li>', '</li>'); ?>
</div>

That will display just the loop of the latest 10 articles. You can then add a heading and styles to it to make it look better.

I also want to go over the Include line above ex:
include('./blog/wp-load.php');
That is tricky situation depending on where your static site is or if it is in a subdirectory.
You might even name the blog directory something different than that. You need to just make sure that that include statement points to the file so you get that functionality you need.

Hope that this helps out. I knew I needed help with how to Include Latest Posts into my HTML Code using a PHP Static Site. If you need any help feel free to reach out to us. We might be able to help you with this or other WordPress problems. Trust the experts at Long Island Web Design for any of your website needs.
How do you rate this? {star-snippet}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Creative Web Design & Marketing, right in Long Island.

Get in touch with us!