Finally figured out the solution. Answering it if anyone finds it useful. Where $_GET['s_qr']
has a search query from a user from another page.
$i = 0;
$parent_name="";
$taxonomyName = "product-cat";
$search_r = array();
$parent_terms = get_terms( $taxonomyName, array( 'parent' => 0, 'orderby' => 'slug', 'hide_empty' => false ) );
foreach ( $parent_terms as $pterm ) {
$parent_name_1 = $pterm->name;
$terms = get_terms( $taxonomyName, array( 'parent' => $pterm->term_id, 'orderby' => 'slug', 'hide_empty' => false ) );
foreach ( $terms as $term ) {
//Find if the the category name has the search query
if (stripos($term->name, $_GET['s_qr']) !== false) {
$search_r['item'][$i] = $term->name. " in ".$parent_name_1;
$i++;
}
}
}
print_r($search_r);
Related Posts:
- The Operator “NOT IN” Does Not Work In tax_query
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- How to have this permalink structure: post_type/postname/custom_inner_page
- How to display Related Posts based on number of taxonomy terms matched
- tax_query not working in template
- WP_query – Filter by tax_query and meta_query using multiple select
- WP_Query parameter conflict
- how to get this tax_query working?
- Custom Category Walker with Image, Fallback to Most Recent Post in Category Image
- tax_query (if the terms are empty)
- custom post type and a “sticky” position taxonomy
- WP Query tax_query not returning posts
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- tax_query showing no results
- WP Query Conditionally query meta and taxonomy
- Display all posts in a custom post type, grouped by a custom taxonomy
- How to put custom post types on front page
- How to add multiple images to a custom post type single post?
- Counting Posts of a Given Post Type Having a Specific Taxonomy?
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- how to group custom post type posts by custom taxonomy terms
- Displaying Posts Related to Other Posts by a Taxonomy Term?
- Querying Posts by Taxonomy From Alternate Network Site
- Combine tax_query and meta_query in WP_Query
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- Multiple Archive Pages for Custom Post Types AND Taxonomies
- Query for posts in 2 taxonomies
- Exclude current post when getting related post on custom post type and taxonomy
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Ordering Custom Post Types with WP_Query
- Paginated Taxonomy Term Archive including one post per term
- How do I create an archive page for standard posts?
- Query for custom post type objects in a taxonomy and with a meta value
- Limit users by custom taxonomy and user roles
- Is it possible to create a shortcode that will query a post based on taxonomies?
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- tax_query returning all posts instead of selective posts in WP_Query
- wp_query to find posts by year and month
- Querying Term Posts in Loop
- Custom Post Type Loop within Shortcode
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Displaying a custom post types custom taxonomy value?
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Query Multiple Taxominies Across Multiple Post type’s
- Display CPT posts based on specific taxonomy
- Filtering WP_Query Dynamically on the Front-End
- What template files do I need to customise custom-category-term-links rather than fall back on archive.php?
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- custom taxonamy and post type
- Custom post taxonomies as tax_query terms?
- Custom WP Query on custom meta and sort by multiple meta keys value
- Custom taxonomies relationship
- Custom Widget WP_Query problem
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- WP_Query orderby and tax_query
- How to produce a sub-page-system in WordPress
- WordPress wp_query() basic question about args
- Custom post type, custom taxonomy, query posts only from taxonomy (children of)
- WP_Query with custom post type ID
- How to get the post terms from a child taxonomy
- display posts of custom post type with custom taxonomy
- Custom post type and custom taxonomy 404 on page 2
- Exclude latest post from WP_Query taxonomy term loop
- WP_Query order custom post type with certain meta key value by post modified date
- Cant’ Display Custom Post Type Title Base on Tax Terms
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Display featured posts for a custom post type by taxonomy
- What is the most efficient way to execute recursive complex queries?
- set object terms after some some time of published post – functions.php
- Sort custom posts by date and then by taxonomy
- have to do a while have post to show for two custom post types sharing the same taxonomy?
- Display related CPT with custom taxonomy
- display post count in archive page that have relation with another taxonomy term
- I have a random letter appearing before my content. Where to start looking for the cause?
- Custom Post Taxonomy Template Not Loading Properly
- WP_Query for custom taxonomies showing posts from non-specified terms?
- How to display only child category post in related posts in custom post type?
- Custom search for a custom post type in WordPress
- tax_query not working?
- Displaying WordPress posts from post and custom post type in custom taxonomy
- Get posts of an specific term of a custom taxonomy
- Checking Taxonomy Terms for a Custom Post Type With get_the_terms Not Working
- Loop carousel slider in wordpress
- WP_Query for CPT with filter by another WP_Query
- show custom taxonomies in hierarchy
- Loop with Custom Post Type and Taxonomies
- How to query posts by meta keys AND under specific category?
- Shortcode display CPT Query only showing 1 post?
- Storing/querying custom date data
- Catergory args causing loop not to show
- Using tax_query to get single post per category
- How to manage wordpress knowledge base/wiki/posts collections
- Get X posts with the same terms as the current post (custom post type and custom taxonomy)
- Default WordPress Query for a Specific Custom Post Type URL
- Sort ACF by custom taxonomy
- Query custom post type and group by taxonomy
- Dynamically count the number of custom post types associated to a custom taxonomy