refactoring build function in api to return html template AND result_amounts

This commit is contained in:
Antoine M 2023-11-17 12:56:18 +01:00
parent 9244fea8e0
commit 5c947839b5

View File

@ -150,7 +150,12 @@ function build_news_posts_feed_all($request)
$html_template = ob_get_clean();
$response = new WP_REST_Response($html_template);
$response_data = array(
'html_template' => $html_template,
'total_posts_found' => $newsPostsDatas->found_posts,
);
$response = new WP_REST_Response($response_data);
$response->set_status(200);
return $response;
@ -194,7 +199,14 @@ function build_news_posts_feed_per_type_id($request)
$html_template = ob_get_clean();
$response = new WP_REST_Response($html_template);
$response_data = array(
'html_template' => $html_template,
'total_posts_found' => $newsPostsDatas->found_posts,
);
$response = new WP_REST_Response($response_data);
$response->set_status(200);
return $response;