Basic Search

Showing $LOADED_ARTICLES of $ARTICLE_COUNT

0, “size” => 10, “_source” => [“postId”], “query” => [ “bool” => [ “should” => [ [ “match”=> [ “excerpt”=> [ “query”=> $_GET[“q”], “boost”=> 2 ] ] ], [ “match”=> [ “authors”=> [ “query”=> $_GET[“q”], “boost”=> 3 ] ] ], [ “match”=> [ “abstract”=> [ “query”=> $_GET[“q”], “boost”=> 1 ] ] ], [ “match”=> [ “title”=> [ “query”=> $_GET[“q”], “boost”=> 3 ] ] ], ], “minimum_should_match”=> 1 ] ], “sort” => [ [ “pubDate” => [ “order” => isset($_GET[“sort”]) ? strtolower($_GET[“sort”]) : “desc” ] ] ] ]; if(isset($_GET[“fdate”])||isset($_GET[“category”])){ $elastic_query[“query”][“bool”][“must”] = []; } if(isset($_GET[“fdate”])){ $elastic_query[“query”][“bool”][“must”][] = [ “range”=> [ “pubDate”=> [ “gte”=> $_GET[“fdate”], “lte”=> $_GET[“ldate”] ] ] ]; } if(isset($_GET[“category”])){ $elastic_query[“query”][“bool”][“must”][] = [ “match_phrase”=> [ “category”=> $_GET[“category”] ] ]; } $elastic_auth = “Basic ” . base64_encode($elastic_info[“username”] . “:” . $elastic_info[“password”]); $elastic_response = wp_remote_post($elastic_info[“host”] . ‘/’ . $elastic_info[“index”] . “/_search”, array(‘body’ => json_encode($elastic_query), ‘sslverify’ => false, ‘headers’ => array(‘Content-Type’ => ‘application/json’, “Authorization” => $elastic_auth))); $elastic_body = wp_remote_retrieve_body($elastic_response); $elastic_data = json_decode($elastic_body, true); $found_posts_articles = $elastic_data[“hits”][“total”][“value”]; if($elastic_data[“hits”][“total”][“value”] > 0){ $ids = []; foreach($elastic_data[“hits”][“hits”] as $hit){ $ids[] = $hit[“_source”][“postId”]; } $args = [ ‘post_type’ => ‘article’, ]; $args[“post__in”] = $ids; $query_articles = new WP_Query($args); $query_articles = $query_articles->posts; $post_index_articles = 0; foreach ($query_articles as $item_articles){ $post_id_articles = $item_articles->ID; $query_articles_meta=get_post_meta($post_id_articles); ?>
get_results($wpdb->prepare(” SELECT {$wpdb->prefix}posts.ID, {$wpdb->prefix}p2p.p2p_id FROM {$wpdb->prefix}p2p, {$wpdb->prefix}posts WHERE p2p_from = %d AND p2p_type = %s AND {$wpdb->prefix}posts.ID = p2p_to ORDER by p2p_id “, $post_id_articles, “article_to_contributor”)); $author_ids[0] = array_map(fn($item) => $item->ID, $c); $author_ids[1] = array_map(fn($item) => $item->p2p_id, $c); if(count($author_ids[0]) > 0): $args = [ ‘post__in’ => $author_ids[0], ‘post_type’=>’contributor’, ‘post_status’ => ‘publish’, ]; $query_authors = new WP_Query($args); $found_posts_authors = $query_authors->found_posts; $query_authors = $query_authors->posts; usort($query_authors, function ($a, $b) use ($args) { return array_search($a->ID, $args[‘post__in’]) <=> array_search($b->ID, $args[‘post__in’]); }); $post_index_authors = 0; foreach ($query_authors as $item_authors){ $post_id_authors = $item_authors->ID; $query_authors_meta=get_post_meta($post_id_authors); ?> and  2){ ?>

and others

Load More