Make WordPress Core

Opened 20 years ago

Closed 19 years ago

#1194 closed defect (bug) (fixed)

dropdown_cats doesn't add the correct selected tag

Reported by: crahan's profile crahan Owned by:
Milestone: 2.1 Priority: normal
Severity: minor Version: 2.1
Component: General Keywords: has-patch 2nd-opinion
Focuses: Cc:

Description

The dropdown_cats parameter to mark the current category as selected in the dropdownlist doesn't work. It can be fixed by changing:

if ($category->cat_ID == $selected)

echo ' selected="selected"';
echo '>';

to

if (is_category($category->cat_ID) && $selected)

echo ' selected="selected"';
echo '>';

Attachments (1)

select_current_category.diff (571 bytes) - added by markjaquith 19 years ago.
Patch for /trunk/

Download all attachments as: .zip

Change History (8)

#1 @crahan
20 years ago

  • Patch set to No

#2 @mdawaffe
19 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Ticket unclear as to where this occurs. I know of no place where this is broken in 2.1. Assuming fixed.

#3 @markjaquith
19 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I verified. If you use it on a category page, it doesn't select the currently-viewed category.

In the fix, definitely reverse the order of the checks.

if ( $selected && is_category($category->cat_ID) )

Don't want to do all those is_category() calls if we don't have to!

I'll crank out a patch here in a minute.

#4 @ryan
19 years ago

Also, see if we can use wp_dropdown_categories() in place of some of the dropdown_cats calls in the admin. I get tired of maintaining both of them.

#5 @markjaquith
19 years ago

  • Keywords has-patch 2nd-opinion added
  • Milestone set to 2.1
  • Version changed from 1.5 to 2.1

Codex say that for the deprecated dropdown_cats() function, "selected" was the ID of the category to be selected, but it should default to the current category. I think we should mimic this behavior in wp_dropdown_categories().

The problem here is that the default is zero, rather than the current category.

Patch sets default to the current category, for is_category() views, 0 otherwise.

#3088 opened for conversion from dropdown_cats() to wp_dropdown_categories()

@markjaquith
19 years ago

Patch for /trunk/

#6 @mdawaffe
19 years ago

markjaquith, thanks for the correction.
+1

#7 @ryan
19 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [4151]) Make the current cat the selected cat when doing a category query. fixes #1194

Note: See TracTickets for help on using tickets.