Skip Navigation

[Resolved] In custom search: When will posts with child terms of searched terms be found?

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by a.R 3 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#2057379

a.R

When searching for posts with a parent term: When will posts with its child terms be found?

e.g.
FRUIT
- APPLE
- BANANA

When will posts with BANANA (but WITHOUT fruit!) be found when searching for FRUIT?

I was given the following code, but it makes fatal errors, even after checking the single quotes.

	add_filter( 'wpv_filter_query', 'taxonomy_view_func', 10, 2 );
	function taxonomy_view_func( $query, $setting ) {
	    if ( $setting['view_id'] = 5522 ) {
	        if ( isset( $query['tax_query'] ) ) {
	            foreach ( $query['tax_query'] as $k => $v ) {
	                if(isset($v['taxonomy']) && $v['taxonomy'] == 'armedium') {
	                    $query['tax_query'][$k]['include_children'] = true;
	                    break;
	                }
	            }
	        }
	    }
	    return $query;
	}

THANK YOU, kind regards,

Achim

#2057395

Hello,

Since it is a custom codes problem, please provide a test site with the same problem, fill below private message box with login details, also point out the problem page URLs, where I can edit your custom PHP codes, I need a live website to test and debug, thanks

#2058619

a.R

Ok, line 4 was missing an equal sign. (And maybe there were some problems with spaces?)
And now, after changing the search to "one of the selected" instead of "all of the selected", VOILA!

Thank you, have a good time!

#2058631

a.R

My issue is resolved now. Thank you!