I checked the rest api urls separately, and i realice it only print the result of 5 posts for each url site, and this is because I had previously created a function to display a custom api rest data, and there I had it defined only for 5 posts, I have increased it and that’s it !!!! everything working great!!!!
So, 1 – The code works sucessfully!!! and 2- This it’s my custom api rest ( Create route and including Aadvanced custom fields data.
function wl_posts() {
$args = [
'post_type' => 'post',
'posts_per_page' => 10 ];
$posts = get_posts($args);
$data = [];
$i = 0;
foreach($posts as $post) {
$data[$i]['id'] = $post->ID;
$data[$i]['title'] = $post->post_title;
$data[$i]['excerpt'] = $post->post_excerpt;
$data ... [ MORE DATA]
$i++; }
return $data; }
add_action('rest_api_init', function() {
register_rest_route('wl/v1', 'posts', [
'methods' => 'GET',
'callback' => 'wl_posts', ]);