Make WordPress Core

Opened 17 years ago

Closed 17 years ago

Last modified 15 years ago

#4596 closed defect (bug) (worksforme)

use_desc_for_title doesnt work in wp_list_categories()

Reported by: tiosolid's profile tiosolid Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.2.1
Component: General Keywords: wp_list_categories categories lists reporter-feedback
Focuses: Cc:

Description (last modified by westi)

When you make a call to wp_list_categories(), the use_desc_for_title is set to TRUE by default, but even if the category has a description, the default text (View all posts filed under..) is shown. Even if you force the use_desc_for_title to TRUE in the wp_list_categories() call, it still doesnt work.

I managed to "fix" this bug changing the line 586 in the classes.php file from:

if ( $use_desc_for_title == 0 || empty($category->category_description) )


if ( empty($category->category_description) )

but, this break the use_desc_for_title variable usage.

Attachments (1)

test_walker_category.php (7.2 KB) - added by darkdragon 17 years ago.
Automattic Automated Tests for Walker Category

Download all attachments as: .zip

Change History (8)

#1 @foolswisdom
17 years ago

  • Milestone set to 2.3 (trunk)

#2 @darkdragon
17 years ago

  • Keywords reporter-feedback added

Question: Was the operator between those two an || or an && when you were having trouble?

This is an interesting bug. However, it appears that Trac removed some formatting from the description. I'm going to try to track down and see what the rest of the string is.

It appears that the line is using the correct logic, however, because of PHP implicit type jungling it is unclear whether your TRUE value is being type casted to INT 1.

It might be better to explicitly type cast $use_desc_for_title to boolean and then test for false value. However, type casting anything to boolean means that an empty variable and 0 will have false value and everything else will have true value.


if( (bool) $use_desc_for_title === false || empty( $category->description ) )

These should have false values:

  • $use_desc_for_title = ''
  • $use_desc_for_title = 0
  • $use_desc_for_title = false

These should have true values:

  • $use_desc_for_title = true
  • $use_desc_for_title = 'a'
  • $use_desc_for_title = 1

It is unlikely that a drastic logic modification like removing the variable check would help anything. The logic itself should be fixed.

#3 @westi
17 years ago

  • Description modified (diff)

fixed description so full text was visible.

#4 follow-up: @darkdragon
17 years ago

I'm going to take ownership of this for the weekend or tonight. If I provide a patch and find a solution, is it possible it can get in? Or is it too early to tell?

#5 in reply to: ↑ 4 @westi
17 years ago

Replying to darkdragon:

I'm going to take ownership of this for the weekend or tonight. If I provide a patch and find a solution, is it possible it can get in? Or is it too early to tell?

Go for it. Patches that fix issues are always appreciated!

#6 @darkdragon
17 years ago

Wait! use_desc_for_title is set to '1' by default. However, it is a string, it will still be type casted to 1, which doesn't equal 0, so the first evaluates to false and unless the description contains something, it will display the first block with "View all posts..."

I'm unsure if the goal is to allow for setting the value to true. In which case, I would have to agree that it should allow you to set the argument to true.

17 years ago

Automattic Automated Tests for Walker Category

#7 @darkdragon
17 years ago

  • Milestone 2.4 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Unit Tests show that this is not a problem. $category->category_description no longer exists and is now $category->description, it is most likely that the problem you were having was fixed on the switch over to Taxonomy API.

Note: See TracTickets for help on using tickets.