query_vars['s']; // https://trello.com/c/JYKEOORU/27-поиск-на-глобал#comment-5e9435ad5214d57738ad73a1 // изменение порядка вывода по запросу $wp_query->query_vars['orderby'] = 'date'; $wp_query->query_vars['order'] = 'desc'; $wp_query->query_vars['search_orderby_title'] = []; // \Dk\Helper\Utils::dump($wp_query); // explode search expression to get search terms $exploded = explode(' ', $terms); if ($exploded === FALSE || count($exploded) == 0) $exploded = array(0 => $terms); // reset search in order to rebuilt it as we whish $where = ''; // get searcheable_acf, a list of advanced custom fields you want to search content in $list_searcheable_acf = list_searcheable_acf(); foreach ($exploded as $tag) { $where .= " AND ( ($wpdb->posts.post_title LIKE '%$tag%') OR ($wpdb->posts.post_content LIKE '%$tag%') OR EXISTS ( SELECT * FROM $wpdb->postmeta WHERE post_id = $wpdb->posts.ID AND ("; foreach ($list_searcheable_acf as $searcheable_acf) : if ($searcheable_acf == $list_searcheable_acf[0]) : $where .= " (meta_key LIKE '%" . $searcheable_acf . "%' AND meta_value LIKE '%$tag%') "; else : $where .= " OR (meta_key LIKE '%" . $searcheable_acf . "%' AND meta_value LIKE '%$tag%') "; endif; endforeach; $where .= ") ) )"; } return $where; } add_filter('posts_search', 'advanced_custom_search', 500, 2); $page->post_title]); $terms = get_terms(array( 'taxonomy' => 'alphabet', 'hide_empty' => true, )); $letter = $terms[0]->slug; $authorTerms = wp_get_post_terms($postId, 'alphabet'); if ($authorTerms) { $letter = $authorTerms[0]->slug; } set_query_var('dk_model_alphabet_data', ['terms' => $terms, 'letter' => $letter]); ?>