Welcome to WebmasterWorld Guest from 54.196.153.46

Forum Moderators: ergophobe

Message Too Old, No Replies

Latest Post from Wordpress onto another site

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

Junior Member

5+ Year Member

joined:Jan 23, 2009
posts: 51
votes: 0


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 June 21, 2009 (gmt 0)

Senior Member from US 

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

joined:Mar 31, 2002
posts:7575
votes: 0


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 June 21, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 23, 2009
posts: 51
votes: 0


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 June 22, 2009 (gmt 0)

Senior Member from US 

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

joined:Mar 31, 2002
posts:7575
votes: 0


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 June 24, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 23, 2009
posts: 51
votes: 0


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 June 25, 2009 (gmt 0)

Moderator This Forum

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

joined:Apr 25, 2002
posts:8326
votes: 155


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 June 25, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2006
posts:2559
votes: 45


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 June 26, 2009 (gmt 0)

Junior Member

5+ Year Member

joined:Jan 23, 2009
posts: 51
votes: 0


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!