$searchQuery = new WP_Query( [
's' => @$data->suggest->text
] );
server {
root /var/www/html/wordpress;
index index.php index.html index.htm;
server_name URL_САЙТА;
client_max_body_size 500M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* .(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|docx|xls|xlsx|exe|pdf|ppt|tar|wav|bmp|rtf|js|svg|svgz)$ {
expires max;
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /phpmyadmin {
alias /usr/share/phpmyadmin/;
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
fastcgi_ignore_client_abort off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
access_log off;
log_not_found off;
expires 1M;
}
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
add_filter( 'graphql_PostObjectsConnectionOrderbyEnum_values', function( $values ){
// RELEASE_DATE — название параметра сортировки
$values['RELEASE_DATE'] = [
'value' => 'release_date', // название meta key
'description' => __( 'Дата выпуска проекта', 'wp-graphql' ), // описание для документации
];
return $values;
});
add_filter( 'graphql_post_object_connection_query_args', function( $query_args, $source, $input ) {
if ( isset( $input['where']['orderby'] ) && is_array( $input['where']['orderby'] ) ) {
foreach( $input['where']['orderby'] as $orderby ) {
if ( !isset( $orderby['field'] ) || $orderby['field'] !== 'release_date' ){
continue;
}
$query_args['meta_key'] = 'release_date'; // название meta key
$query_args['orderby'] = 'meta_value';
$query_args['order'] = $orderby['order'];
}
}
return $query_args;
}, 10, 3);