Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#10393 closed defect (bug) (fixed)

wp_tag_cloud('order=RAND') broken with PHP >= 5.2.10

Reported by: Joern_W Owned by:
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.1
Component: General Keywords:
Focuses: Cc:


From PHP 5.2.10 the result of array_rand is no longer shuffled. So the output of wp_tag_cloud('order=RAND') is no longer shuffled.

possible solution:
in file category-template.php replace

elseif ( 'RAND' == $order ) {

$keys = (array) array_rand( $tags, count( $tags ) );
$temp = array();
foreach ( $keys as $key )

$temp[$key] = $tags[$key];

$tags = $temp;
$temp = null;
unset( $temp );



elseif ( 'RAND' == $order ) {

shuffle( $tags );


Attachments (1)

10393.patch (2.0 KB) - added by azaozz 11 years ago.

Download all attachments as: .zip

Change History (3)

11 years ago

#1 @azaozz
11 years ago

  • Milestone changed from Unassigned to 2.9

The patch contains the suggested change with a small improvement. When sorting randomly what's the point of sorting by count first?

Also not sure how apply_filters( 'tag_cloud_sort', $tags, $args ); is supposed to be used. Is it there so plugins can "re-sort" the already sorted array? Perhaps it needs to be moved up and let a plugin replace the sorting methods, not add more sorting.

#2 @azaozz
11 years ago

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

(In [11744]) Fix wp_tag_cloud('order=RAND'), don't pre-sort if filter 'tag_cloud_sort' is used to sort the tags, props Joern_W, fixes #10393

Note: See TracTickets for help on using tickets.