Black Hat Forum Black Hat SEO The only backlink provider with unlimited projects/links per day!
Go Back   Black Hat Forum Black Hat SEO > BlackHatWorld > BlackHat Lounge

BlackHat Lounge What’s been on your mind lately? Maybe you've come across a website that made you laugh. Almost anything goes here!

Mad Content   BLOG SEO
Search
 
LinkWheel

LiveChatAgent



Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-2009, 05:38 AM
tony-raymondo's Avatar
Junior Member
 
Join Date: Jun 2009
Location: USA
Posts: 147
Thanks: 168
Thanked 418 Times in 149 Posts
Reputation: 50
iTrader: (0)
Default Integrate wordpress with front page - just want to display the last 10 posts on index.htm

So i have a website with a /blog directory

I want to showcare the last 5 posts from that blog on my front page.

Anyone ever seen a little php modules / code snippets to place in the index.htm, to do this?
__________________
You don't have to be crazy to work here, but it helps!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-09-2009, 05:52 AM
Newbies
 
Join Date: Oct 2009
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Reputation: 10
iTrader: (0)
Default Re: Integrate wordpress with front page - just want to display the last 10 posts on index.

You can try the following php code that would grab the latest 5 posts directly from your wordpress database.

Note: This is only a sample code. DB info file, Modifications/Additions required to make it work as intended.

PHP Code:
<?php
include ('db_info.inc');
$con mysql_connect($hostname$dbuser$dbpass);
$select mysql_select_db ($selectdb$con);
$query "SELECT * FROM wp_posts WHERE post_status = 'publish' ORDER BY ID DESC LIMIT 5";
$result mysql_query ($query$con);
$number_rows mysql_num_rows ($result);
if (
$number_rows == 0)
{
$error_message "No posts yet.";
echo (
"$error_message");
}

else
{
echo (
"<h2>Last 5 Blog Posts</h2>");
while (
$row mysql_fetch_array ($result))
{
// construct variables to capture post title, post content and guid (url)
// You may want to curtail the length of post content
}

echo (
"
// Format the output using post title, post content and guid variables
"
);

}
?>

Last edited by kmoore; 11-09-2009 at 05:54 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


SEO Paladin


Web Hosting
Copyright © 2005 - 2012 BlackHatWorld.com All rights reserved.