#4335 closed defect (bug) (fixed)
Intrinsic Category Sorting (by ID) Changed in 2.2
Reported by: | iacas | Owned by: | |
---|---|---|---|
Milestone: | 2.2.1 | Priority: | normal |
Severity: | normal | Version: | 2.2 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
Category sorting used to take place by ID, and without a proper "primary category," I'm now finding with WordPress 2.2 that the permalinks as well as the order of the categories is flipped from previous behavior.
I've written about this more here: http://tinyurl.com/yp3vfn
I'd like to call this a bug as the behavior, so far as I can tell, was unplanned and unannounced, and I'd like the behavior reverted.
Attachments (1)
Change History (9)
#2
@
18 years ago
Otto, so far as I can tell this change is from 2.1.x to 2.2. I have PHP 4.3.9 installed.
Permalinks used to be built from the category with the lowest ID. Now they're built from the category with the highest ID. Category lists used to be in "low to high" order, and now that order too appears reversed.
I'm using only standard WP functions. I don't manually build my own URLs.
Some specific examples:
http://thesandtrap.com/tags/reviews/eagle_sticks_golf_club_zanesville_oh_review
versus
http://thesandtrap.com/courses/eagle_sticks_golf_club_zanesville_oh_review
or
http://thesandtrap.com/tags/hot_topics/the_cost_of_being_a_fan
versus
http://thesandtrap.com/the_numbers_game/the_cost_of_being_a_fan
#3
@
18 years ago
I believe I've worked around this - for now - by setting the categories with cat_ID of 98, 99, 100, and 101 to their negatives: -98, -99, -100, and -101. Corresponding updates to wp_post2cat were also made (UPDATE wp_post2cat set category_id = '-99' WHERE category_id = '99')
I still believe this type of behavior is a bug - the behavior changed, unannounced and I believe unintended - and it certainly highlights the need for a "primary" category feature since categories are (often) intrinsic to URL-building in WordPress.
#4
@
18 years ago
$cats = get_the_category($post->ID); $category = $cats[0]->category_nicename;
We need to sort cats by ID before taking setting $category to the first cat in the list.
#6
@
18 years ago
There's a patch for 2.2. Try that on for size.
I'm leaving this out of the codebase until [4349] gets fixed in trunk, so I can commit fixes to both branches at the same time without risk of regression.
What categories? What sort? What function are you calling to do what? Categories changed a lot between 2.0 and 2.1, so it's difficult to understand what it is that you're doing here. Even reading your blog post left me unenlightened.
What is the PHP code that you are running, or what are you doing exactly?
What does it do, for each version of Wordpress?
What did you expect it to do instead?
That's what we need to know.