Ticket #4335 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Intrinsic Category Sorting (by ID) Changed in 2.2

Reported by: iacas Assigned to: anonymous
Priority: normal Milestone: 2.2.1
Component: General Version: 2.2
Severity: normal Keywords:
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

cat_id_order__branches_2.2.diff (1.1 kB) - added by markjaquith on 05/28/07 06:02:05.
Pick category-based post permalink by lowest category ID (patch for 2.2 branch)

Change History

05/25/07 14:30:01 changed by Otto42

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.

05/25/07 15:07:49 changed by iacas

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

05/25/07 15:43:18 changed by iacas

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.

05/25/07 23:35:16 changed by ryan

			$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.

05/25/07 23:35:41 changed by ryan

That's in get_permalink().

05/28/07 05:58:11 changed by markjaquith

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.

05/28/07 06:02:05 changed by markjaquith

  • attachment cat_id_order__branches_2.2.diff added.

Pick category-based post permalink by lowest category ID (patch for 2.2 branch)

05/29/07 04:54:45 changed by markjaquith

  • status changed from new to closed.
  • resolution set to fixed.

(In [5590]) switch to term_id and name for category sorting. see #4189. sort by term_id for category permalinks, by name for get_the_category(). fixes #4335 for trunk. Props Erik Barzeski for the find.

05/29/07 04:56:51 changed by markjaquith

(In [5591]) sort by cat_ID for category permalinks, by name for get_the_category(). fixes #4335 for 2.2. Props Erik Barzeski for the find.