[wp-testers] get_category Ordering Weirdness?

Tom Belknap dragonfly at dragonflyeye.net
Thu Dec 20 15:34:14 GMT 2007


Hello all!

I'm using WPMU 1.3, which is the 2.3.1 codebase, and experiencing some problems with the get_categories function and what appears to be an ordering problem.  If I choose to order by ID or by name, ascending or descending, the results are different in each case, which suggests that the function must at least be *trying* to order the list.  However, the list never comes out right.

Here is my code:
<?php
require('./wp-blog-header.php');

switch_to_blog(6);
$categories = get_categories('orderby=ID&order=desc');

print('<pre>');
print_r($categories);
print('</pre>');

?>

And here is my result set:

Array
(
    [0] => stdClass Object
        (
            [term_id] => 95
            [name] => Template Functions
            [slug] => template-functions
            [term_group] => 0
            [term_taxonomy_id] => 11
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 1
            [cat_ID] => 95
            [category_count] => 1
            [category_description] => 
            [cat_name] => Template Functions
            [category_nicename] => template-functions
            [category_parent] => 0
        )

    [1] => stdClass Object
        (
            [term_id] => 33
            [name] => Reference
            [slug] => reference
            [term_group] => 0
            [term_taxonomy_id] => 9
            [taxonomy] => category
            [description] => Reference materials on WordPress functionality
            [parent] => 0
            [count] => 0
            [cat_ID] => 33
            [category_count] => 0
            [category_description] => Reference materials on WordPress functionality
            [cat_name] => Reference
            [category_nicename] => reference
            [category_parent] => 0
        )

    [2] => stdClass Object
        (
            [term_id] => 96
            [name] => Functions
            [slug] => functions
            [term_group] => 0
            [term_taxonomy_id] => 12
            [taxonomy] => category
            [description] => 
            [parent] => 33
            [count] => 32
            [cat_ID] => 96
            [category_count] => 32
            [category_description] => 
            [cat_name] => Functions
            [category_nicename] => functions
            [category_parent] => 33
        )

    [3] => stdClass Object
        (
            [term_id] => 31
            [name] => Actions
            [slug] => actions
            [term_group] => 0
            [term_taxonomy_id] => 8
            [taxonomy] => category
            [description] => 
            [parent] => 33
            [count] => 1
            [cat_ID] => 31
            [category_count] => 1
            [category_description] => 
            [cat_name] => Actions
            [category_nicename] => actions
            [category_parent] => 33
        )

    [4] => stdClass Object
        (
            [term_id] => 30
            [name] => Hooks
            [slug] => hooks
            [term_group] => 0
            [term_taxonomy_id] => 7
            [taxonomy] => category
            [description] => 
            [parent] => 33
            [count] => 1
            [cat_ID] => 30
            [category_count] => 1
            [category_description] => 
            [cat_name] => Hooks
            [category_nicename] => hooks
            [category_parent] => 33
        )

    [5] => stdClass Object
        (
            [term_id] => 13
            [name] => Plugin Concepts
            [slug] => plugins
            [term_group] => 0
            [term_taxonomy_id] => 4
            [taxonomy] => category
            [description] => General discussion of how plugins for WP/WPMU work
            [parent] => 33
            [count] => 3
            [cat_ID] => 13
            [category_count] => 3
            [category_description] => General discussion of how plugins for WP/WPMU work
            [cat_name] => Plugin Concepts
            [category_nicename] => plugins
            [category_parent] => 33
        )

    [6] => stdClass Object
        (
            [term_id] => 29
            [name] => Blog Info
            [slug] => blog-info
            [term_group] => 0
            [term_taxonomy_id] => 6
            [taxonomy] => category
            [description] => Posts germane to this blog, not pertaining to WordPress.
            [parent] => 0
            [count] => 1
            [cat_ID] => 29
            [category_count] => 1
            [category_description] => Posts germane to this blog, not pertaining to WordPress.
            [cat_name] => Blog Info
            [category_nicename] => blog-info
            [category_parent] => 0
        )

    [7] => stdClass Object
        (
            [term_id] => 21
            [name] => WPMU
            [slug] => wpmu
            [term_group] => 0
            [term_taxonomy_id] => 5
            [taxonomy] => category
            [description] => Plugins for WordPress Multi-User
            [parent] => 0
            [count] => 3
            [cat_ID] => 21
            [category_count] => 3
            [category_description] => Plugins for WordPress Multi-User
            [cat_name] => WPMU
            [category_nicename] => wpmu
            [category_parent] => 0
        )

    [8] => stdClass Object
        (
            [term_id] => 36
            [name] => Hacks
            [slug] => hacks
            [term_group] => 0
            [term_taxonomy_id] => 10
            [taxonomy] => category
            [description] => Not plugins, but I'll walk you through a few core-hacks that have worked for me.
            [parent] => 21
            [count] => 2
            [cat_ID] => 36
            [category_count] => 2
            [category_description] => Not plugins, but I'll walk you through a few core-hacks that have worked for me.
            [cat_name] => Hacks
            [category_nicename] => hacks
            [category_parent] => 21
        )

    [10] => stdClass Object
        (
            [term_id] => 1
            [name] => Uncategorized
            [slug] => uncategorized
            [term_group] => 0
            [term_taxonomy_id] => 1
            [taxonomy] => category
            [description] => 
            [parent] => 0
            [count] => 1
            [cat_ID] => 1
            [category_count] => 1
            [category_description] => 
            [cat_name] => Uncategorized
            [category_nicename] => uncategorized
            [category_parent] => 0
        )

)

This is a blog created directly on the MU 1.2 version.  Does anyone else see these same problems or no?  Is this affecting anyone using 2.3.1?  Anyone using MU 1.3?

Thank you very much.
Tom Belknap


More information about the wp-testers mailing list