Use the terms_clauses
filter, which passes all the various components of the query (fields, join, where, orderby, order & limits), and implement your own “search” argument:
function wpse_178511_get_terms_fields( $clauses, $taxonomies, $args ) {
if ( ! empty( $args['surname'] ) ) {
global $wpdb;
$surname_like = $wpdb->esc_like( $args['surname'] );
if ( ! isset( $clauses['where'] ) )
$clauses['where'] = '1=1';
$clauses['where'] .= $wpdb->prepare( " AND t.name LIKE %s OR t.name LIKE %s", "$surname_like%", "% $surname_like%" );
}
return $clauses;
}
add_filter( 'terms_clauses', 'wpse_178511_get_terms_fields', 10, 3 );
Put in use:
get_terms( 'my_taxonomy', 'surname=E' );
Related Posts:
- 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
- Control term order on a per-post basis
- Fixing category count
- How can I get category ID by category name?
- Elegant way to add parent categories?
- How can I select a primary category?
- Programmatically create product category and add thumbnail in woocommerce
- How to order the get_categories result
- 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
- Update term count using a callback function
- Get terms that are associated with products from current category
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- 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
- Use get_term_children to get the sub category of a parent category for the current post
- Action hooks returning old category instead of new category
- Update wordpress post terms programatically
- Display empty taxonomy terms with get_terms()
- Get a list of Terms for a specific category
- When to use ‘get_category_by_path’ vs. ‘get_term_by’ to get category object from `get_query_var( ‘category_name’ )`?
- List Terms in Category
- How do I get a list of all categories that a given user has written blog posts for?
- Set post categories to include parents when setting child category
- How to get data about category in category.php
- Limit number of terms that a custom taxonomy can save per custom post type
- Inserting Category programmatically
- How can i insert term in a specific language of Polylang?
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- Display Posts Loop for each parent and for each Child
- Is There a Difference Between Taxonomies and Categories?
- Get posts from specific taxonomy term
- Get posts under a category with SQL
- Getting category URL with hyphens, not spaces
- get_terms function not returning anything
- Display custom taxonomy attached to the post on post single page
- wp_dropdown_categories not showing option as selected
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Get a count of how many times a term or a category is used in posts
- Get Categories Where Taxonomy Equals ‘n’
- Display sibling categories on category page
- Count tags for a specific category
- How to Link to Most Recent Custom Post of Same Term
- set terms to category and subcategory
- Getting Category Children
- More efficient way to list posts by category [duplicate]
- Showing HTML if Post is In Certain Taxonomy Term
- Exclude categories by ID
- Using in ‘category_name’ in ‘$query->set();’?
- How to store category and tags separatly on wordpress?
- Post to inherit custom category background image from parent
- wp_delete_term or wp_delete_category?
- Update custom category fields front-end
- Combining these queries? (Same taxonomy term + same category as post)
- WP-CLI Add category as menu item main-menu
- Add properties to term object
- get_object_term_cache duplicate terms after update to wordpress 6
- List taxonomy terms assigned to a post in hierarchical view
- Sort categories by custom field in WordPress admin
- 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?
- outputting taxonomy hierarchy
- Bulk Change WordPress category Slug
- Add subcategories posts to the counts column at the admin’s categories list
- show only terms from parent category
- Categories and Tags Conflict after Woocommerce Installation
- Get category of a taxonomy for a queries object in a loop
- get_terms sort order with child categories of varying depth
- Getting a sub category based on a category name
- Getting Post Tags From Certain Categories
- Display List of Categories Within a Custom Taxonomy
- List Terms by category
- get_adjacent_post_link excluded_terms ignored
- How to add a new child category via an SQL statement?
- Why is my post categories not displaying?
- exclude parents from the_terms
- Problem importing categories and sub-categories
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- Use get variable when rewritten url in wordpress
- 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
- hide_empty property not working when using get_terms
- How to convert regular categories to custom taxonomy?
- Checkboxes in the category list?