made pagination and mostly finalized the searchbox
This commit is contained in:
@@ -127,12 +127,18 @@ class Partnerexpo_Core_Public {
|
||||
|
||||
$query = new WP_Query_WithRelevance($args);
|
||||
|
||||
$response = [
|
||||
'pages' => $query->max_num_pages,
|
||||
'found' => $query->found_posts,
|
||||
'results' => [],
|
||||
];
|
||||
|
||||
$posts = [];
|
||||
|
||||
foreach ($query->posts as $post) {
|
||||
$tags = wp_get_post_terms($post->ID, 'pexpo_tags', ['fields' => 'names']);
|
||||
|
||||
$posts[] = [
|
||||
$response['results'][] = [
|
||||
'id' => $post->ID,
|
||||
'title' => $post->post_title,
|
||||
'image' => get_the_post_thumbnail_url($post->ID),
|
||||
@@ -140,13 +146,12 @@ class Partnerexpo_Core_Public {
|
||||
'date' => date('Y-m-d', strtotime($post->post_date)),
|
||||
'tag' => $tags ?? null,
|
||||
'url' => get_permalink($post),
|
||||
'order' => $params['sort'] ?? 'relevance',
|
||||
];
|
||||
}
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
return rest_ensure_response($posts);
|
||||
return rest_ensure_response($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user