made pagination and mostly finalized the searchbox

This commit is contained in:
2026-02-11 21:26:19 +01:00
parent 2f8396d994
commit 9ea053986d
5 changed files with 186 additions and 35 deletions

View File

@@ -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);
}
/**