Integrate multiple Wordpress excerpts problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ringartdesign
Forum Newbie
Posts: 21
Joined: Wed Sep 10, 2008 10:11 am

Integrate multiple Wordpress excerpts problem

Post by ringartdesign »

I have a website that pulls 3 different wordpress blogs excerpts into it. I've gotten the php to pull the wordpress content in the 3 instances, but it pulls 1 blog instance into all three spots regardless of the path it calls. See the site:http://halfpricewinenight.com/blog.php http://halfpricewinenight.com/thingswelike.php http://halfpricewinenight.com/wineoftheweek.php

Now for the code for the instance on the middle left "Blog" excerpt:
<?php
/* PHP to pull and publish wordpress 2 post data on an external page NO CACHE*/
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php');

$how_many=1; //How many posts do you want to show
require_once("blog/wp-config.php");
// strip out html characters to allow for truncating
$strippedDesc = strip_tags($html, $news);
// truncate post content to 12 words
$numwords = 12;
preg_match("/([\S]+\s*){0,$numwords}/", $strippedDesc, $regs);
$shortDesc = trim($regs[0]);
// Change this for your path to wp-config.php file

$news=$wpdb->get_results("SELECT `ID`,`post_title`,
`post_excerpt` FROM $wpdb->posts
WHERE `post_status`= \"publish\"
ORDER BY 'ID' DESC LIMIT ".$how_many);
foreach($news as $np){

//NOTE: get other post data by selecting different
//data in the posts table...

$permalink=get_permalink($np->ID);

$html= "<p><a href=\"". $permalink .
"\">$np->post_title</a><br/>
$np->post_excerpt\n</p>";

//NOTE: you can easily alter the HTML above to suit

echo $html;

}
?>
Post Reply