homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Content Management
Forum Library, Charter, Moderators: ergophobe

Content Management Forum

    
Latest Post from Wordpress onto another site
whyyi




msg:3937861
 8:03 pm on Jun 21, 2009 (gmt 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!

 

lorax




msg:3937887
 9:23 pm on Jun 21, 2009 (gmt 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.

whyyi




msg:3937890
 9:29 pm on Jun 21, 2009 (gmt 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.

lorax




msg:3938246
 2:41 pm on Jun 22, 2009 (gmt 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.

whyyi




msg:3939658
 6:11 pm on Jun 24, 2009 (gmt 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!

ergophobe




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

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]

londrum




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

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];

whyyi




msg:3941280
 8:59 pm on Jun 26, 2009 (gmt 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!

Global Options:
 top home search open messages active posts  
 

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

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved