I have three custom fields (not using ACF). I want the search form to search for a match in:
_cth_featured_zip_code_1
_cth_featured_zip_code_2
_cth_featured_zip_code_3
This is the query I've written:
$wpdb->prepare(
" LEFT JOIN $wpdb->postmeta AS laddress_meta ON laddress_meta.post_id = {$wpdb->posts}.ID AND laddress_meta.meta_key = %s",
'_cth_featured_zip_code_1','_cth_featured_zip_code_2','_cth_featured_zip_code_3'
);
Am I thinking about this correctly? i.e. does this statement accomplish joining the post meta table and asking it to search just those fields from within that table?
When I go to test, it looks like all I get are results that match the first custom field listed. When I try adding in another 'AND' or 'OR' condition while trying to include the other two fields, this causes a critical error on the site.
What's the proper way to query the other 2 custom fields in addition to the first? Is there another operator I should be using? I've spend most the morning getting the join piece figured out - I'm getting hung up here.
Any even slight confirmation in the right direction would be greatly appreciated.