ACF::posts_where() public ACF 5.8.1
Filters the $where clause allowing for custom WP_Query args.
{} Это метод класса: ACF{}
Хуков нет.
Возвращает
WP_Query
. $wp_query The query object.
Использование
$ACF = new ACF(); $ACF->posts_where( $where, $wp_query );
- $where(строка) (обязательный)
- The WHERE clause.
- $wp_query (обязательный)
- -
Список изменений
С версии 5.8.1 | Введена. |
Код ACF::posts_where() ACF::posts where ACF 5.9.1
function posts_where( $where, $wp_query ) {
global $wpdb;
// Add custom "acf_field_key" arg.
if( $field_key = $wp_query->get('acf_field_key') ) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_name = %s", $field_key );
}
// Add custom "acf_field_name" arg.
if( $field_name = $wp_query->get('acf_field_name') ) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_excerpt = %s", $field_name );
}
// Add custom "acf_group_key" arg.
if( $group_key = $wp_query->get('acf_group_key') ) {
$where .= $wpdb->prepare(" AND {$wpdb->posts}.post_name = %s", $group_key );
}
// Return.
return $where;
}