Join

Unlock Custom Taxonomies Within MyListing Quick Search

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

MyListing does not allow users to search for Listings using Custom Taxonomies within the Quick Search Bar by default.

These code snippets and the How to Unlock Custom Taxonomies With MyListing Quick Search guide help you overcome this limitation.

Code Snippet 1

Replace the ‘Custom Tax’ entries with the actual names of your own Custom Taxonomies.

$GLOBALS['CUSTOM_TAX_FOR_QUICK_SEARCH']=["Custom Tax 1","Custom Tax 2","Custom Tax 3"];

Code Snippet 2

if($GLOBALS['CUSTOM_TAX_FOR_QUICK_SEARCH']){
	foreach($GLOBALS['CUSTOM_TAX_FOR_QUICK_SEARCH'] as $tax){
		$sections[strtolower($tax)] = $this->get_terms( [
			'title' => _x( $tax, 'Quick search > '. $tax . ' section title', 'my-listing' ),
			'taxonomy' => strtolower($tax),
			'search_term' => $search_term,
		] );

	}
}