WordPress.org

Support

Support » WP-Advanced » How do I limit my search on post’s title only?

How do I limit my search on post’s title only?

  • How do I limit my search on post’s title only?

    Below are my codes.

    <h3><?php _e('Search','k2_domain'); ?></h3>
    <div id="search" class="widget widget_search">
    <form id="searchform" method="get" action="http://www.mydomain.com">
    <div>
    <input type="text" name="s" id="s" size="15" />
    <input type="submit" value="Search" />
    </div></form>
    </div>
    <br class="clear" />
Viewing 2 replies - 1 through 2 (of 2 total)
  • anschorr

    @anschorr

    bumping this as i need it too.
    any ideas?

    1.open wp-includes/query.php

    2.search for

    $search .= “{$searchand}((post_title LIKE ‘{$n}{$term}{$n}’) OR (post_content LIKE ‘{$n}{$term}{$n}’))”;

    3.remove the OR part.

    to be specific

    $search .= “{$searchand}((post_title LIKE ‘{$n}{$term}{$n}’))”;

    4.if u want exact title search, change it to

    $search .= “{$searchand}((post_title='{$term}’))”;

    LOL
    -sangeetha 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I limit my search on post’s title only?’ is closed to new replies.
Skip to toolbar