• The optional excerpt is not searched by default or at all.
    I could write a plugin that does this I suppose, but its one of those things that one would assume got searched.

    Its trivial to add, you just change three lines in wp-includes/classes.php:
    from:

    if (!$q['sentence']) {
    $s_array = explode(' ',$q['s']);
    $q['search_terms'] = $s_array;
    $search .= '((post_title LIKE ''.$n.$s_array[0].$n.'') OR (post_content LIKE ''.$n.$s_array[0].$n.''))';
    for ( $i = 1; $i < count($s_array); $i = $i + 1) {
    $search .= ' AND ((post_title LIKE ''.$n.$s_array[$i].$n.'') OR (post_content LIKE ''.$n.$s_array[$i].$n.''))';
    }
    $search .= ' OR (post_title LIKE ''.$n.$q['s'].$n.'') OR (post_content LIKE ''.$n.$q['s'].$n.'')';
    $search .= ')';
    } else {
    $search = ' AND ((post_title LIKE ''.$n.$q['s'].$n.'') OR (post_content LIKE ''.$n.$q['s'].$n.''))';
    }
    to
    if (!$q['sentence']) {
    $s_array = explode(' ',$q['s']);
    $q['search_terms'] = $s_array;
    $search .= '((post_title LIKE ''.$n.$s_array[0].$n.'') OR (post_content LIKE ''.$n.$s_array[0].$n.''))';
    for ( $i = 1; $i < count($s_array); $i = $i + 1) {
    $search .= ' AND ((post_title LIKE ''.$n.$s_array[$i].$n.'') OR (post_content LIKE ''.$n.$s_array[$i].$n.'') OR (post_excerpt LIKE ''.$n.$s_array[$i].$n.''))';
    }
    $search .= ' OR (post_title LIKE ''.$n.$q['s'].$n.'') OR (post_content LIKE ''.$n.$q['s'].$n.'') OR (post_excerpt LIKE ''.$n.$q['s'].$n.'')';
    $search .= ')';
    } else {
    $search = ' AND ((post_title LIKE ''.$n.$q['s'].$n.'') OR (post_content LIKE ''.$n.$q['s'].$n.'') OR (post_excerpt LIKE ''.$n.$q['s'].$n.''))';
    }

    Give me a good reason why WP shouldn’t search the excerpt by default?(if its not there it just won’t be searched)

Viewing 1 replies (of 1 total)
  • Let’s say you search a blog for X. But when going through the results, none of the posts are actually shown to have X because it’s only in the excerpt, not the content.

    I’m not claiming this is the reason behind the limited records WordPress will perform a search on, as I’m neither one of the WP developers nor have seen a thorough write-up of the search facilities in WP. But is that expected behavior to you?

Viewing 1 replies (of 1 total)
  • The topic ‘Search Post Excerpt’ is closed to new replies.