Create a “Recent Posts” Module Outside of WordPress
This post was rewritten on Monday, September 24, 2012
I've never created a complete client website using WordPress, but many of those websites do have a WordPress blog to compliment the website. Oftentimes the client will want to list recent blog posts within the website, not within the WordPress shell. No problem -- creating a recent posts module, or any Query-based usage of WordPress posts, is incredibly easy!
The key to using WordPress outside of WordPress is include the
// Include the wp-load'er
// Get the last 10 posts
// Returns posts as arrays instead of get_posts' objects
$recent_posts = wp_get_recent_posts(array(
'numberposts' => 10
// Do something with them
wp-load.php file is included, the entire wealth of WordPress functions is provided to you. While the sample code above gets recent posts, you can do your own custom queries with WP_Query or get_posts().
New York, NY · October 12-14
Get 20% off with
It's no secret that Facebook has become a major traffic driver for all types of websites. Nowadays even large corporations steer consumers toward their Facebook pages instead of the corporate websites directly. And of course there are Facebook "Like" and "Recommend" widgets on every website. One...
With Firefox OS, asm.js, and the push for browser performance improvements, canvas and WebGL technologies are opening a world of possibilities. I featured 9 Mind-Blowing Canvas Demos and then took it up a level with 9 Mind-Blowing WebGL Demos, but I want to outdo...
One of the reasons I love AJAX technology so much is because it allows us to avoid unnecessary page loads. Why download the header, footer, and other static data multiple times if that specific data never changes? It's a waste of time, processing, and bandwidth. Unfortunately...