making bbPress (and WordPress) work better!

List WordPress post titles, etc. outside of WordPress

There are probably many mentions of how to do this around the web and forums, but I couldn’t quickly find any code samples so I came up with my own by hacking the RSS templates. Using this snippet you can list post titles, even exceprts or comments outside of WordPress on your website without having to go through the web interface.

It’s as simple as creating a new PHP file. ie. newest.php in your wordpress root (topmost folder) and then including it in any other file on your website that is outside of wordpress with:

<? @include ($_SERVER['DOCUMENT_ROOT'].'/wordpress/newest.php'); ?>

Here’s the code for “newest.php”

<?php $limit=6; $more=1; $count=1;

if (empty($wp)) {require_once('wp-config.php'); wp('feed=rss');}

if ($posts) { foreach ($posts as $post) { start_wp(); ?>

<a href="<?php permalink_single_rss() ?>" /><?php the_title_rss() ?></a><br>

<?php $count++; if ($count > $limit) { break; } } } ?>

That will list the latest post titles, up to limit you set (I chose 6).
It’s easy to add excerpts, etc to that code if you study the rss & rss comments templates.

4 responses

  1. Gwyn Moxham

    What part of this code is generating the number at the start? I want to remove this if possible but I’m no PHP guru!

    February 14, 2009 at 1:07 pm

  2. chris

    How would i get the post text and the date it was posted included and not just the title.

    August 26, 2009 at 11:26 am

  3. Also, can we Fletch post content or excerpt with the list ? I found a plugin “W4 post list” which can do all this features. But still some restriction there. Google for this plug

    February 28, 2011 at 2:39 pm

  4. If an individual bust feed or pregnant, speak with a medical professional clenched fists.

    Research is, of program, primary. Another vital thing is
    pertaining to the dose.

    December 19, 2013 at 9:25 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s