Results 1 to 2 of 2

Thread: simple title search

  1. #1
    Thread Starter
    Rookie igc8's Avatar
    Join Date
    Jul 2011
    Location
    Russian Federation
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question simple title search

    hi everyone!

    lets talk about search in classipress.

    i need fast search over only titles of ad listings, not over all filds and categiries.

    i find this solution for wp but it not work in classipress can any one add this to classipress?

    Code:
    В файл functions.php добавьте:
    
    function __search_by_title_only( $search, &$wp_query )
    {
        if ( empty($search) )
            return $search; // skip processing - no search term in query
        $q =& $wp_query->query_vars;
        // wp-includes/query.php line 2128 (version 3.1)
        $n = !empty($q['exact']) ? '' : '%';
        $searchand = '';
        foreach( (array) $q['search_terms'] as $term ) {
            $term = esc_sql( like_escape( $term ) );
            $search .= "{$searchand}($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
            $searchand = ' AND ';
        }
        $term = esc_sql( like_escape( $q['s'] ) );
        if ( empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
            $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}')";
        if ( !empty($search) ) {
            $search = " AND ({$search}) ";
            if ( !is_user_logged_in() )
                $search .= " AND ($wpdb->posts.post_password = '') ";
        }
        return $search;
    }
    add_filter( 'posts_search', '__search_by_title_only', 10, 2 );

  2. #2
    Thread Starter
    Rookie igc8's Avatar
    Join Date
    Jul 2011
    Location
    Russian Federation
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How remove category name and time under ad title in search results
    By inwal in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: April 2nd, 2012, 04:35 PM
  2. Search auto-complete by ad title?
    By jorgeantonio in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: January 30th, 2012, 11:28 AM
  3. Search not including title or description
    By sposner in forum Report ClassiPress Bugs
    Replies: 2
    Last Post: October 18th, 2011, 02:38 PM
  4. [MOD NEEDED] Search results category in the Meta Title
    By ddashwood in forum ClassiPress General Discussion
    Replies: 5
    Last Post: May 5th, 2011, 05:41 AM
  5. [MOD NEEDED] Modify search for just title
    By doctorcilantro in forum ClassiPress General Discussion
    Replies: 2
    Last Post: March 12th, 2011, 08:43 PM