homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

Put Latest Posts Feed On Static Page?

 3:27 pm on Apr 5, 2012 (gmt 0)

Hi there, Everyone:

Is there an easy way to show the title, excerpt, and link from the 5 most recent posts on a static page?

I like how the various Latest Post widgets work in wordpress, and I wonder if there is a way to replicate that on the home page of my site, which is kind of a static page (actually uses Miva script, but that's another story).

Thanks in advance.



 3:43 pm on Apr 5, 2012 (gmt 0)

Do you mean static as in non-WordPress or static as in a WordPress Page?


 4:29 pm on Apr 5, 2012 (gmt 0)

It's confusing because Wordpress refers to "static pages" meaning Wordpress generated pages, but they are anything but static. For the purpose of discussion, when I say "static" it means an actual hard file, like index.html.

If the latter is the case, this is the exact same answer as the post here [webmasterworld.com] with a twist. If Miva dynamically outputs pages via PHP, you can skip the bits about static HTML, just follow the parts about wp-load and query_posts.

If you want to drop **any** Wordpress element into a static page, you'll need to initiate a Wordpress instance. So The first thing you'd do is rename the main page index.php*.

Once you do that, you include wp-load:

<?php include ($_SERVER['DOCUMENT_ROOT'] . "/blog/wp-load.php"); ?>

Now, anywhere in your page, you can pull posts from anywhere - the example in the link above pulls the 5 latest posts from categories 6 and 12.

* If you're linking directly to index.html, you shouldn't be. Links to main should be just / or example.com/. So instead of jumping through hoops trying to keep the main page name index.html (like parsing HTML as PHP, or worrying about changing all your links, or something) add a mod_rewrite directive (or IIS equivalent) to permanently redirect any requests for /index.html to /. This will allow you to rename the main page as index.php without any problems.


 7:29 pm on Apr 5, 2012 (gmt 0)

Hi again, and sorry for the confusion:

to clarify, what I would like to do is show the post links / excerpts on a NON-wordpress page.

what I think I have to do is:

1) Create a new page in wordpress that uses the code rocknbill linked to.

2) In my Miva page (the static page), use a function that renders that whole new wordpress page (it is kind of like an iframe, but doesn't use the iframe tags - I guess it is similar to a php include statement).

Thanks for pointing me in the right direction. I will try it out and see how it goes.


 7:54 pm on Apr 5, 2012 (gmt 0)

Ok, i am part way there, but have a problem or two:

First, i created a FILE called


I put this code in it:

<?php include ($_SERVER['DOCUMENT_ROOT'] . "/blog/wp-load.php"); ?>
while (have_posts()) {
$date = get_the_date();
$permalink = get_permalink();
$title = get_the_title();
echo "<p><a href=\"$permalink\" title=\"$title\">$title</a><br>$date By: ";
echo '</p>';

Note that I modified rocknbill's code slightly and removed the


from the line:


Because I wanted to show the latest posts REGARDLESS of which category they were in.

Here are the Issues:

1) For some reason, it returns 7 posts instead of only 5 posts, despite having


2) They don't seem to be in any order. It would be best if I could show the most recent at the top

Thanks in advance.


 11:59 pm on Apr 5, 2012 (gmt 0)

Have you been to the docs [codex.wordpress.org]?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved