Answers for "limit wordpress search to title"

PHP
0

none

// Place this in function.php
function search_by_title( $search, $wp_query ) {
    if ( ! empty( $search ) && ! empty( $wp_query->query_vars['search_terms'] ) ) {
        global $wpdb;

        $q = $wp_query->query_vars;
        $n = ! empty( $q['exact'] ) ? '' : '%';

        $search = array();

        foreach ( ( array ) $q['search_terms'] as $term )
            $search
Posted by: Guest on January-01-1970

Browse Popular Code Answers by Language