[wp-hackers] Proposed: list_cats() - display 'All' only when fewer than all displayed

Dennis Williamson dennis at netstrata.com
Mon Oct 11 19:53:51 UTC 2004


I've attached a diff that makes some changes to list_cats() in 
template-functions-category.php CVS revision 1.39.

The change causes list_cats() to display optionall only when fewer than all 
categories are being displayed.

Dennis

Index: template-functions-category.php
===================================================================
RCS file: 
/cvsroot/cafelog/wordpress/wp-includes/template-functions-category.php,v
retrieving revision 1.39
diff -u -3 -r1.39 template-functions-category.php
--- template-functions-category.php	10 Aug 2004 05:35:59 -0000	1.39
+++ template-functions-category.php	4 Oct 2004 18:25:47 -0000
@@ -286,6 +295,7 @@
  function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', 
$sort_order = 'asc', $file = '', $list = true, $optiondates = 0, 
$optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, 
$children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', 
$feed_image = '', $exclude = '', $hierarchical=FALSE) {
  	global $wpdb, $category_posts;
  	global $querystring_start, $querystring_equal, $querystring_separator;
+	global $cat;
  	// Optiondates now works
  	if ('' == $file) {
  		$file = get_settings('home') . '/' . get_settings('blogfilename');
@@ -343,7 +353,7 @@
  		}
  	}
  	
-	if (intval($optionall) == 1 && !$child_of && $categories) {
+	if (intval($optionall) == 1 && !$child_of && $categories && !empty($cat) 
&& $cat != 'all' && $cat != '0') { // don't display all if it is already all
  		$all = apply_filters('list_cats', $all);
  		$link = "<a 
href=\"".$file.$querystring_start.'cat'.$querystring_equal.'all">'.$all."</a>";
  		if ($list) {






More information about the hackers mailing list