0

I am using the following code to search some data from WordPress database, but when first condition is false then OR condition is not working.

 $where .= ' AND ((' . $wpdb->posts . '.post_title LIKE '.$search_term.') || ('. $wpdb->postmeta. '.meta_value LIKE '.$search_term.'))';
3

1 Answer 1

0

The problem is strictly with your query... or to be more precise, with your misunderstanding of your query ;)

You've put || in there and you assume it is OR operator, but... depending on configuration of server it can act as OR or... string concatenation ;)

So change it to OR and it should work fine, I guess...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.