我已經看到了這段代碼。該代碼顯示數據庫中最新的10個WordPress帖子的標題標題。我需要做的是從這個中消除一個特定的類別。誰能幫忙?如何從查詢中刪除特定類別
<?php require_once 'news/wp-config.php';
$howMany = 0;
$query ="SELECT `ID`, `post_title`,'post_category', `guid`,SUBSTRING_INDEX(`post_content`, ' ', 100) AS `post_excerpt` FROM $wpdb->posts WHERE `post_status`= \"publish\" AND `post_type` = \"post\" ";
$posts = $wpdb->get_results($query);
$posts = array_reverse($posts);
foreach($posts as $post)
{
if($howmany<10)
{
$link = $post->guid;
echo "<li><a target='_blank' href='$link'>$post->post_title</a></li>";
$howmany++;
}
}
?>
似乎沒有工作。 – amit 2009-07-26 12:22:54
呃 - 你是否真的嘗試過,還是用'布告欄'替換3? where'post_status` = \「publish \」AND`post_type` = \「post \」AND post_category!= \「Noticeboard \」「 – 2009-07-26 12:38:41
當然我做過了:) – amit 2009-07-26 19:00:32