posts_join

最后更新于:2021-11-27 15:00:07

apply_filters_ref_array( ‘posts_join’, string $join, GC_Query $query )

Filters the JOIN clause of the query.

参数

$join

(string)
The JOIN clause of the query.

$query

(GC_Query)
The GC_Query instance (passed by reference).

源文件

文件: gc-includes/class-gc-query.php

View on Trac

function AIO_AlphabeticSearch_WhereString( $where, &$gc_query )
{
    global $gcdb;
    if(isset($_GET['aioAlphaSearchMode']) && $_GET['aioAlphaSearchMode'] == 1){

        $searchAlphabet = esc_sql($_GET['s']); 

        $where .= ' AND ' . $gcdb->posts . '.post_title LIKE ''.$searchAlphabet.'%' ';

        // use only if the post meta db table has been joined to the search tables using posts_join filter
        $where .= " AND ($gcdb->postmeta.meta_key = 'JDReview_CustomFields_ReivewOrNewsPostType' AND $gcdb->postmeta.meta_value = 'JDReview_PostType_ReviewPost') ";
        return $where;
    }
}

add_filter( 'posts_where', 'AIO_AlphabeticSearch_WhereString', 10, 2 );