STEPS FOR CREATE WORDPRESS REST API
Download WordPress plugin for REST API from below link
Login to WordPress admin panel through SITE_URL/wp-login.php Then in sidebar of dashboard
Go to option ‘PLUGINS’
Click on Add New
upload downloaded plugin
Active that plugin
Then check below link for API (i.e, SITE_URL/wp-json/wp/v2/posts ) You will get list of posts which are added in website http://itechnotion.in/wp-news/wp-json/wp/v2/posts
There is list of APIs for getting different types of data (i.e, posts, categories, comments, etc.) That list I have attached at end of this document.
If there is need to add extra fields which aren’t providing by default API, then you need to add custom function for adding extra fields in below file /wp-content/themes/themename/functions.php I have added some custom functions there for adding extra needed fields.
And for contact_us form & add comment form, I have written two APIs there in /api folder.
LIST OF REST APIs
1) For getting all posts(GET method)
For fetching next posts
For getting limited posts(i.e, for getting only two records)
2) For getting post by post id(GET method)
3) For getting all categories: (GET method)
4) For getting category by category id: (GET method)
5) For getting all posts by category id: (GET method)
6) Search posts by keyword: (GET method)
7) For getting comments for post: (GET method)
Link for adding custom APIs for add comment & contact us:
Download zip from above link and put in root directory of server then unzip it in root directory. It will add that custom API files in api directory.
8) For contact us: (POST method)
9) For adding comment: (POST method)
1) post_id // 617
2) comment_author // itech
3) comment_author_email // email@example.com
4) comment_content // test comment
// If adding comment without login then pass zero as `user_id`
else pass value of `user_id`