You can write a get_the_terms filter to change the other the category values are returned, e.g.
function sort_the_terms( $terms, $post_id, $taxonomy ) {
if ( 'categories' === $taxonomy ) {
usort( $terms, function( $term1, $term2 ) {
// Better sort logic here
return $term1->name <=> $term2->name;
} );
}
return $terms;
}
add_filter( 'get_the_terms', 'sort_the_terms', 20, 3 );
You’ll need to change the logic in the comparator to get the order you want, e.g. using information in wp_termmeta or the group or parent ID of the term. (If you’re using parents to build a hierarchy you might need something more complicated than just a usort though, since ‘place in hierarchy’ is going to be difficult to determine completely in a comparator.)
Related Posts:
- Order get_terms() By Custom Field
- How to Change the Categories Order in the Admin Dashboard?
- Sort posts by tags in category pages
- Display all posts in category, with specific tag posts at top
- I want to order categories based upon the latest post time
- WordPress Ordering Problem. How to fix ordering 1-10-100 issue?
- Order posts by category name
- Custom order categories in admin dashboard
- Arrange posts by date in front page
- How to redefine the sorting of product categories by menu_order?
- Order categories by name or view count
- WooCommerce – How to show specific category first-rest of products-specific category last
- Custom taxonomy/category order
- I want to display the all the posts that are inside a certain subcategory
- wp e-commerce group product by category [closed]
- List posts in alphabetical order
- Custom loop of a single category, cannot order by date. What am I missing?
- How do order product categories – on a parent category page – in Woocommerce?
- Natural sort / ordering wp_dropdown_categories
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- How can I order all subcategories alphabetical independent of the parent categories?
- Ordering terms whilst in loop
- Modifying category order
- Configure query with multiple categories in a custom order?
- $args Orderby The number
- Woocommerce custom taxonomy order
- Woocommerce – Display product category of product in Orders page
- Post list category plugin alphabetical order [closed]
- How to remove categories filter from wordpress admin?
- Get page content by category or tag
- Rewrite category wordpress
- categories on attachment page
- How to only show posts on last child category
- Changing the category permalink structure
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- Page with the same name of a category
- Creating Pages that show specific blog categories [closed]
- If a post belongs to two categories how do I choose the main category?
- Change post category based on latest posts views
- in_category() works in single.php but not in page.php?
- functions.php conditional tag – only show in single.php?
- How to enable category hierarchy for links?
- How do I create a way for users to assign categories to a post from the frontend of the website?
- Get categories from save_post hook
- Display category name on featured image in wordpress excerpt
- I need to create a search form that will display search results from specific category
- Is it possible to restrict viewing of category PAGE to logged in users only?
- Display children of the category a post is assigned to
- Random post + categories + tags
- Second level subcategory
- how to define category loop last class in the third
- Making the category & tag Description textarea bigger
- WordPress admin categories sort show is wrong
- Huge category CSV import does not work
- Needing a snippet for listing category specific tags
- Displaying Categories and Sub Categories
- How to list categories within tags?
- get_next_post set the category
- WordPress URL Rewrite for dynamic and customized URL
- Pagination for ajax category filter
- Get posts from specific taxonomy term
- limit a list of tags to one category [closed]
- How many categories can WordPress handle before performance suffers?
- WordPress Drop down category as array for using in page builder
- Get sort order of product categories
- How to pull a list of posts in a category while exluding posts in subcategories of the category
- Exclude category from query
- How to show the category of custom taxonomy
- Showing HTML if Post is In Certain Taxonomy Term
- Add code to header based on category for specific posts?
- Can I prioritize post categories for choice for breadcrumb trail?
- Category List with custom urls
- Get a list of all links on a page?
- Load the last post of a category
- create function to call category name and slug
- Disable Category Taxonomy
- A different permalink structure for different categories
- How to make product image inherit from category image
- Is it possible to set up blog categories without changing permalink structure
- How to display categories image in loop homepage WordPress
- How to “remove” WordPress categories UL and make the list loop in a horizontal line?
- how to give different template to each subcategory from same parent category?
- No hierarchy in wp_list_categories with child of and depth
- How do I rewrite a single category link to point to a custom page?
- Add subcategories posts to the counts column at the admin’s categories list
- WordPress update 4.7 – the 70.000+ news posts became “Uncategorized”
- Problem with wp_list_categories
- Display one post on category.php: Wrong featured image
- Display related posts with same category or same tag return blank
- Get posts from 2 or more categories
- Taxonomy for custom post type not found
- date.php shows all posts. how to fix it?
- Help with Wp + Mixitup code
- How can I get this code to only output one link?
- Sorting Woocommerce products by category and attributes
- How to get Woocomerce categories count
- show posts from some category and sort by advance custom field
- how to create a page that shows all of multiple category posts on a single page
- Quick Edit on taxonomy names results in error