示例#1
0
/**
 * Modify search results page with results from Better Search. Filters posts_orderby.
 *
 * @since	1.3.3
 *
 * @param	string $orderby    ORDERBY clause of main query
 * @param	object $query      WordPress query
 * @return	Formatted ORDERBY clause
 */
function bsearch_orderby_clause($orderby, $query)
{
    global $wpdb, $bsearch_settings;
    if ($query->is_search() && $bsearch_settings['seamless'] && !is_admin() && $query->is_main_query()) {
        $search_ids = bsearch_clause_prepare();
        if ('' != $search_ids) {
            $orderby = " FIELD( {$wpdb->posts}.ID, {$search_ids} ) ";
        }
    }
    /**
     * Filters Better Search ORDERBY clause
     *
     * @since	2.0.0
     *
     * @param	string	$where	ORDERBY clause of main query
     * @param	object	$query	WordPress query
     */
    return apply_filters('bsearch_orderby_clause', $orderby, $query);
}
示例#2
0
/**
 * Modify search results page with results from Better Search. Filters posts_orderby.
 *
 * @param object $query
 */
function bsearch_orderby_clause($orderby)
{
    global $wp_query, $wpdb, $bsearch_settings;
    if ($wp_query->is_search && $bsearch_settings['seamless'] && !is_admin()) {
        $search_ids = bsearch_clause_prepare();
        if ('' != $search_ids) {
            $orderby = " FIELD( {$wpdb->posts}.ID, {$search_ids} ) ";
        }
    }
    return $orderby;
}