I am trying to get the ticker plugin to display only posts, I don't care about categories it can show all but I don't want it to display pages as it's doing.
It's not recognizing either I believe because the table updates for 2.5?
Anyway, here is the heart of the query, I can post more if needed, working locally.
global $wpdb;
$post_table = $wpdb->posts;
$cat_table = $wpdb->post2cat;
if (!empty($category_filters)) {
$catString = explode(",", str_replace(" ", "", $category_filters));
if (count($catString) > 1) { // multiple categories
$cat_query_string = "(";
foreach($catString as $c) {
$cat_query_string .= "$cat_table.category_id = '{$c}' OR ";
}
$cat_query_string = substr($cat_query_string, 0, -4);
$cat_query_string .= ")";
}
else $cat_query_string = "$cat_table.category_id = '{$category_filters}'"; // single category
$query = mysql_query("SELECT $post_table.*, $cat_table.* FROM $post_table, $cat_table WHERE {$cat_query_string} AND $post_table.ID = $cat_table.post_id AND post_status = 'publish' AND post_type = ‘post’ ORDER BY post_date DESC LIMIT $post_offset, $post_limit");
}
else {
$query = mysql_query("SELECT * FROM $post_table WHERE post_status = 'publish' ORDER BY post_date DESC LIMIT $post_offset, $post_limit");
}
if (mysql_num_rows($query) > 0) :
echo "<script type=\"text/javascript\">\n";
echo "var ticker = {\n";
echo "items: " . mysql_num_rows($query) . ",\n";
while ($row = mysql_fetch_assoc($query)) :
$titles .= "'" . addslashes($row['post_title']) . "', ";
$blurbs .= "'" . addslashes(substr(strip_tags(str_replace("\r\n", " ", $row['post_content'])), 0, $blurb_length)) . ".. ', ";
$links .= "'" . addslashes($row['guid']) . "', ";
endwhile;