I have a simple question, but can't find the answer anywhere. What exactly does the 's' parameter search when used in a query? Ex:

$args = array( 's' => $keyword ); $query = new WP_Query($args);

Does it just search post content, or does it also look at title, tags, etc?

EDIT: Just to clarify. The question is what post fields are being searched, not what data is being returned.

  • The default fields being searched are post content and post title. – Nicolai May 26 '15 at 19:36

As usual it's most reliable to dump the resulting SQL query and see:

SELECT wp_posts.ID
FROM wp_posts
  AND (((wp_posts.post_title LIKE '%keyword%')
        OR (wp_posts.post_content LIKE '%keyword%')))
  AND wp_posts.post_type = 'post'
  AND ((wp_posts.post_status = 'publish'))
ORDER BY wp_posts.post_date DESC LIMIT 0,5

The only two things native search is considering are title and content.

  • 1
    Great, thanks for the help! I didn't realize that you could dump the query itself but I'll check that out – Jeremiah Prummer May 27 '15 at 2:29
  • 3
    $wpdb->last_query :) – Rarst May 27 '15 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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