Add_Custom_Fields_To_Search::cf_search_join( string $join )
cf_search_join
Contents
Description Description
Join posts and postmeta tables
See also See also
Parameters Parameters
- $join
-
(string) (Required)
Return Return
(void)
Source Source
File: includes/class-add-custom-fields-to-search.php
function cf_search_join( $join ) { global $wpdb; if ( ! is_search() || $this->is_media_library() ) { return $join; } //join to search post meta values like year, make, model, trim, etc $join .=' LEFT JOIN '.$wpdb->postmeta. ' ON '. $wpdb->posts . '.ID = ' . $wpdb->postmeta . '.post_id '; //these joins are so taxonomy terms like Sport Utility Vehicle => suv are included $join .= 'LEFT JOIN ' . $wpdb->term_relationships . ' tr ON ' . $wpdb->posts . '.ID = tr.object_id ' . 'INNER JOIN ' . $wpdb->term_taxonomy . ' tt ON tt.term_taxonomy_id = tr.term_taxonomy_id ' . 'INNER JOIN ' . $wpdb->terms . ' t ON t.term_id = tt.term_id '; return $join; }
Expand full source code Collapse full source code View on Github