Rich

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
in reply to: Display categories in hierarchical order #48435

Rich
Participant

I actually found an easy solution!

I added the following code to my theme’s functions.php file, and now the categories are all sorted by hierarchy instead of alphabetically.

// Change order of Custom Taxonomy List
http://wordpress.stackexchange.com/questions/7440/change-order-of-custom-taxonomy-list

function set_the_terms_in_order ( $terms, $id, $taxonomy ) {
$terms = wp_cache_get( $id, “{$taxonomy}_relationships_sorted” );
if ( false === $terms ) {
$terms = wp_get_object_terms( $id, $taxonomy, array( ‘orderby’ ► ‘term_order’ ) );
wp_cache_add($id, $terms, $taxonomy . ‘_relationships_sorted’);
}
return $terms;
}
add_filter( ‘get_the_terms’, ‘set_the_terms_in_order’ , 10, 4 );

function do_the_terms_in_order () {
global $wp_taxonomies; //fixed missing semicolon
// the following relates to tags, but you can add more lines like this for any taxonomy
$wp_taxonomies[‘post_tag’]->sort = true;
$wp_taxonomies[‘post_tag’]->args = array( ‘orderby’ ► ‘term_order’ );
}
add_action( ‘init’, ‘do_the_terms_in_order’);

in reply to: Sorting documents alphabetically at the front end #48433

Rich
Participant

Hello,

I am also wondering if there is a fix for this yet?

I know you can set the order to list by title initially by using [order_by=”title”] but the sort order changes once you click on a category.

I also need the option to sort by title added to the search drop down menu on the front end.

Any update?

Thanks.

Viewing 2 posts - 1 through 2 (of 2 total)