Hooked to filter ‘posts_where’ and output the query, it has full UUIDs in it??
-
This is kind of an obscure question.
I have a localhost test site that is bare, just for testing on and such. I have three plugins installed:
Advanced Custom Fields
Brizy
Custom Post Type UII created a custom post type “Companies” and then a couple bogus companies.
I created another CPT “Job Listings”.
I used ACF to add a “Post Object” to the Job Listing so that you can select the company where the job is. Pretty straight forward.Now when I go to the Job Listings page, it lists the jobs, but I have no way to search by company. So if I wanted to find all jobs by Walmart, I couldn’t, not with the default search bar.
So then I added code to functions.php and hooked in to the filter “posts_where”. https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where
At this point I did not alter the WHERE clause at all, I simply printed it to the error log so I could have a look.
This is what the default WHERE looks like:
AND (((wp_posts.post_title LIKE '{9528de73eda4be161aa7e7aa87a8e437e0acb467c96668688d92f58e924765d2}searchterm{9528de73eda4be161aa7e7aa87a8e437e0acb467c96668688d92f58e924765d2}') OR (wp_posts.post_excerpt LIKE '{9528de73eda4be161aa7e7aa87a8e437e0acb467c96668688d92f58e924765d2}searchterm{9528de73eda4be161aa7e7aa87a8e437e0acb467c96668688d92f58e924765d2}') OR (wp_posts.post_content LIKE '{9528de73eda4be161aa7e7aa87a8e437e0acb467c96668688d92f58e924765d2}searchterm{9528de73eda4be161aa7e7aa87a8e437e0acb467c96668688d92f58e924765d2}'))) AND wp_posts.post_type = 'job_listings' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private')
So my question is, what is with the giant UUID-looking things on either side of the search term?
Will the search even work this way?Help me understand what I’m seeing here.
Thanks
- The topic ‘Hooked to filter ‘posts_where’ and output the query, it has full UUIDs in it??’ is closed to new replies.