homepage Welcome to WebmasterWorld Guest from 54.145.172.149
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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

5+ Year Member



 
Msg#: 3937859 posted 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

WebmasterWorld Administrator lorax us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3937859 posted 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

5+ Year Member



 
Msg#: 3937859 posted 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

WebmasterWorld Administrator lorax us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3937859 posted 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

5+ Year Member



 
Msg#: 3937859 posted 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

WebmasterWorld Administrator ergophobe us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3937859 posted 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

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 3937859 posted 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

5+ Year Member



 
Msg#: 3937859 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved