Fixed category name bug. "When excluding a category by using '$cat = "-4";' in index.php, the name of the excluded cat is added to the page title."

git-svn-id: http://svn.automattic.com/wordpress/trunk@814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
mikelittle 2004-01-31 00:03:51 +00:00
parent 5f76df2bec
commit a644a1018b
2 changed files with 11 additions and 3 deletions

View File

@ -151,6 +151,9 @@ if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) {
$cat = ''.urldecode($cat).'';
$cat = addslashes_gpc($cat);
if (stristr($cat,'-')) {
// Note: if we have a negative, we ignore all the positives. It must
// always mean 'everything /except/ this one'. We should be able to do
// multiple negatives but we don't :-(
$eq = '!=';
$andor = 'AND';
$cat = explode('-',$cat);
@ -168,6 +171,9 @@ if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) {
$whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' ');
}
$whichcat .= ')';
if ($eq == '!=') {
$cat = '-'.$cat; //put back the knowledge that we are excluding a category.
}
}
// Category stuff for nice URIs
@ -374,6 +380,6 @@ if ($posts) {
if ($s && empty($paged)) { // If they were doing a search and got one result
header('Location: ' . get_permalink($posts[0]->ID));
}
}
}
}
} // end if posts.
?>

View File

@ -65,7 +65,9 @@ function wp_title($sep = '»', $display = true) {
// If there's a category
if(!empty($cat)) {
$title = stripslashes(get_the_category_by_ID($cat));
if (!stristr($cat,'-')) { // category excluded
$title = stripslashes(get_the_category_by_ID($cat));
}
}
if (!empty($category_name)) {
$title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));