我对通过AJAX加载的搜索结果的顺序有问题,它与搜索结果页面上相同查询的顺序不匹配。AJAX响应WP\\U查询实例使用以下参数:
$query_args = [
\'cat\' => \'-7\',
\'orderby\' => \'relevance\',
\'order\' => \'DESC\',
\'post_type\' => [\'features\', \'how-to-guides\', \'post\', \'page\', \'testimonials\'],
\'posts_per_page\' => 8,
\'post_status\' => \'publish\',
\'s\' => (isset($_GET[\'search_term\']) === true) ? filter_input(INPUT_GET, \'search_term\', FILTER_SANITIZE_SPECIAL_CHARS) : \'\',
\'meta_query\' => [
[
\'compare\' => \'NOT EXISTS\',
\'key\' => \'thank_you_page\',
\'value\' => \'on\',
\'type\' => \'CHAR\'
]
],
\'tax_query\' => [
[
\'field\' => \'slug\',
\'operator\' => \'NOT IN\',
\'taxonomy\' => \'resources-categories\',
\'terms\' => [\'hidden\']
]
]
];
我尝试从查询中删除除order、orderby之外的所有内容,无论orderby是否设置为“DESC”、“ASC”或orderby是否设置为“相关性”、“标题”等,都不会影响AJAX结果的顺序。
以前有没有其他人遇到过这个问题?如果有,您是否找到了一种方法使订单与搜索结果页面上的相同查询相匹配?