Thank you for all the comments! With your help I managed to rule out a standard WordPress issue. I couldn’t find the culprit (As @DaveRomsey suggested, it could be one of the get_terms
or get_terms_orderby
hooks altering results). In any case, I solved it by sorting the array:
$searchedterms = get_terms( 'category', array(
'name__like' => $s,
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => true
) );
function cmp($a, $b){
return strcmp($a->name, $b->name);
}
usort($searchedterms, "cmp");
Related Posts:
- Sort categories by custom field in WordPress admin
- Is There a Difference Between Taxonomies and Categories?
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- get_terms vs. get_categories: does it matter?
- Woocommerce get category image full size
- Order get_terms() By Custom Field
- WordPress Multiple Category Search
- Control term order on a per-post basis
- Fixing category count
- How can I get category ID by category name?
- Exclude categories from search query
- get_terms name__like list categories according to letter
- Elegant way to add parent categories?
- How can I select a primary category?
- Sort posts by tags in category pages
- How to search for categories and/or tags?
- Programmatically create product category and add thumbnail in woocommerce
- How to order the get_categories result
- Sticky posts on home page, search, tag and archives without plugin
- Create product category and keyword search form in woocommerce? [closed]
- Send an email when custom post type category is changed
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Excluding posts from a category but only if they’re not in multiple categories
- How to create a category and sub-category sorted blogroll with all posts?
- Sort category page with custom field
- Update term count using a callback function
- Get terms that are associated with products from current category
- Custom Query to search through categories
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- How to show empty category in admin menus search
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Getting the sub category
- How to select product category while adding new product in woocommerce? [closed]
- Use get_term_children to get the sub category of a parent category for the current post
- How do I get the total number of categories in a list of search results?
- Action hooks returning old category instead of new category
- Update wordpress post terms programatically
- Display empty taxonomy terms with get_terms()
- Category Search functionality on category metabox (wordpress admin)
- Search by word, category, tag, author
- Get a list of Terms for a specific category
- Filtering search results
- When to use ‘get_category_by_path’ vs. ‘get_term_by’ to get category object from `get_query_var( ‘category_name’ )`?
- Help with multiple dropdown tags search
- Filter posts under multiple categories?
- List Terms in Category
- WordPress Default Category and Custom Taxonomy Selected Attribute not Working After Searched in wp_dropdown_categories Array
- Automatically adding tags and categories into Post Excerpt for searching
- List taxonomy terms assigned to a post in hierarchical view
- Return all Tags and Categories in Separate List
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Ordering terms whilst in loop
- Replace deprecated get_category_children code with get_terms
- Can’t display posts by filtering categories using isotope.js
- How to remove parent category from child category url using wordpress rewrite rule?
- Get WooCommerce product category list in functions.php
- Restrict retrieved terms by category?
- List non-empty categories from a custom post type
- How to modify custom category field from front end?
- Woocommerce Category Sort Dropdown
- outputting taxonomy hierarchy
- Search Replace Database ONLY for posts of certain category?
- Bulk Change WordPress category Slug
- Add subcategories posts to the counts column at the admin’s categories list
- Search by tag, category and author without plugin
- show only terms from parent category
- Issue with WordPress category search
- Categories and Tags Conflict after Woocommerce Installation
- Get category of a taxonomy for a queries object in a loop
- Getting a sub category based on a category name
- Getting Post Tags From Certain Categories
- Display List of Categories Within a Custom Taxonomy
- 404 error when i try to search by category or by tag
- Make related posts display first in search result
- A search box for all sites – Multisite
- List Terms by category
- get_adjacent_post_link excluded_terms ignored
- How to add a new child category via an SQL statement?
- Several loop in search result
- Why is my post categories not displaying?
- exclude parents from the_terms
- Problem importing categories and sub-categories
- Sort categories by meta value
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- Use get variable when rewritten url in wordpress
- Search functionality with multiple categories
- Query posts that have all the specified tags
- Display category tree of a post in search results
- Issue on Listing Sub Product Categories In Woocommerce
- get_category_children/ the new get_term_children not work
- Taxonomy term RestApi data 10 rows limitions
- List the category tree of all the product_cat categories
- Remove “All categories” from searchbar dropdown
- hide_empty property not working when using get_terms
- Sort Category Archive pages and place sticky posts first
- Display different sidebar based on search results from one category
- Using same term for slug and category
- When using get_terms with hide_empty = true, terms that only contain scheduled posts are not returned. How to override this?