Make rest api endpoint public

[ad_1]

Guys I’m trying to enable WordPress rest api endpoint and works when I logged in BUT for public appears:

{
“code”: “rest_not_logged_in”,
“message”: “You are not currently logged in.”,
“data”: {
“status”: 401
}
}

some of you knows how can I make public this endpoint? is just a GET OF DATA

The way I got it is:

public function register_people_rest_route() {
register_rest_route(
‘wp/v2’,
‘/people’,
array(
‘methods’ => ‘GET’,
‘callback’ => array( $this, ‘get_people_data’ ),
)
);
}

[ad_2]
1 Comment
  1. You’re probably missing 
    `add_action( ‘rest_api_init’, ‘register_people_rest_route’)`

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer