Created
December 6, 2017 10:48
-
-
Save dingo-d/95cb64baa001afffbdead5e1b02f3d7a to your computer and use it in GitHub Desktop.
Modification of the search query in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT rezultat, ord | |
FROM ( | |
SELECT wp_posts.post_title rezultat, 1 ord, wp_posts.ID ID, wp_posts.post_type type, wp_posts.post_status status FROM wp_posts WHERE wp_posts.post_title LIKE '%search query%' | |
UNION | |
SELECT wp_posts.post_content rezultat, 2 ord, wp_posts.ID ID, wp_posts.post_type type, wp_posts.post_status status FROM wp_posts WHERE wp_posts.post_content LIKE '%search query%' | |
UNION | |
SELECT wp_postmeta.meta_value rezultat, 3 ord, wp_postmeta.post_id ID, 1 type, 1 status FROM wp_postmeta WHERE wp_postmeta.meta_value LIKE '%search query%' | |
) rez | |
WHERE 1=1 | |
AND (rez.type = 'post' OR rez.type = 'page' OR rez.type = 'faq-type') | |
AND rez.type != 'wpcf7_contact_form' | |
AND rez.type != 'revision' | |
AND rez.status = 'publish' | |
ORDER BY ord ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment