WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#8609 closed defect (bug) (fixed)

Tag cloud order priority is broken

Reported by: brh Owned by:
Milestone: 2.7.1 Priority: normal
Severity: normal Version: 2.7
Component: General Keywords: has-patch
Focuses: Cc:

Description

If you specify the order parameter (ASC or DESC) for wp_tag_cloud, you get the opposite ordering you asked for.

On line 654 of category-template.php, there's some code that looks like this:

if ( 'DESC' == $order )

$tags = array_reverse( $tags, true );

But up at line 560, the query that gets the tags always uses DESC. So reversing it gets an ascending order. Line 654 should be changed to "if ( 'ASC' == $order )". Beyond that, having ASC as a default for ordering something on frequency is kind of odd, don't you think?

Attachments (2)

category-template.diff (561 bytes) - added by mrmist 10 years ago.
Category template fixes count order by for trunk
category-template27.diff (504 bytes) - added by mrmist 10 years ago.
Category template diff fixes count orderby for 2.7

Download all attachments as: .zip

Change History (8)

#1 @mrmist
10 years ago

Tag cloud ordering works for me in 2.7

#2 @brh
10 years ago

Try it with these options:

<?php wp_tag_cloud('format=list&orderby=count&order=DESC&number=10'); ?>

You'd expect the most common tags on top, right? You can just look at the code, too - it does a "DESC" ordering in the select, then reverses it if you have the "DESC" order option. Thus it selects the top 10 most popular tags, and then displays them from least popular to most popular.

@mrmist
10 years ago

Category template fixes count order by for trunk

@mrmist
10 years ago

Category template diff fixes count orderby for 2.7

#3 @mrmist
10 years ago

  • Keywords has-patch needs-testing added
  • Milestone changed from 2.8 to 2.7.1

I see what you mean now, I was looking at the default ordering, which is by tag name, and works as expected. Attached fixes orderby COUNT. May need testing.

#4 @mrmist
10 years ago

  • Keywords needs-testing removed

#5 @azaozz
10 years ago

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

(In [10316]) Fix ASC/DESC tag ordering by count, props mrmist, fixes #8609 for trunk

#6 @azaozz
10 years ago

(In [10317]) Fix ASC/DESC tag ordering by count, props mrmist, fixes #8609 for 2.7

Note: See TracTickets for help on using tickets.