Welcome to WebmasterWorld Guest from 54.159.214.250

Forum Moderators: ergophobe

Latest Post from Wordpress onto another site

   
8:03 pm on Jun 21, 2009 (gmt 0)

5+ Year Member



I've got a wordpress blog in a directory on my server (/blog) and my main site on the root of the server. Is there anyway to grab the latest blog post and place it somewhere on the index page of my site preferably without using rss.

Any help is greatly appreciated!

9:23 pm on Jun 21, 2009 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Sure - you'll need a PHP coder to do it though. The WordPress info is in a database that should be readily accessible if they're both on the same server. Alternately, you could simply use the PHP include() to pull in relevant portions of WordPress's core functions and execute the WordPress loop to gather the same information.
9:29 pm on Jun 21, 2009 (gmt 0)

5+ Year Member



thanks for the reply. Are there any examples out there, I couldn't find anything for the life of me. Also, what core functions of wordpress do you need to include.
2:41 pm on Jun 22, 2009 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I'm not sure. I did Google searches for terms like: wordpress recent posts outside website static. I can't remember what I actually found under this but I'd suggest a trip to the WP forums and searches via Google (or your fav SE) using different combos of relevant keywords.
6:11 pm on Jun 24, 2009 (gmt 0)

5+ Year Member



Thanks, It's been a couple days and I've looked high and low and can't find anything that would work. I found a lot of things on making a page static on wordpress, and wordpress loops, but can't find any examples that would pull the latest post onto a site. Everybody talks about doing it but I haven't seen any actual examples.

Thanks again for all the help!

4:47 pm on Jun 25, 2009 (gmt 0)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The PHP/MySQL would be fairly simple - just a query to find out what the post is and integrate it into your site.

Do you know PHP? If so, it shouldn't be that hard.

If not, you might want to hire someone, although this thread could be enough for you:

Basics of extracting data from MySQL using PHP [webmasterworld.com]

5:07 pm on Jun 25, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



i haven't tried it out, but something like this should work.
you just have to connect to the database and then look in the
wp_posts
table (it might have a different extension at the front, depending on how you installed it).

you can grab the post's title, text, excerpt or whatever you want from there.

$query = "SELECT * FROM wp_posts ORDER BY post_date LIMIT 1";

$returns = mysql_query($query);

$result = mysql_fetch_row($returns);

and then...

$post_title = $result[5];

$post_excerpt = $result[7];
8:59 pm on Jun 26, 2009 (gmt 0)

5+ Year Member



Thank You! Thank you so much worked like a charm. Here is my working example for adding the latest post:

$query = "SELECT * FROM wp_posts ORDER BY post_date DESC LIMIT 1";

$returns = mysql_query($query);
$result = mysql_fetch_row($returns);
$post_title = $result[5];
$post_excerpt = $result[7];

echo $post_title;

THANK YOU AGAIN!

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month