You can create a route for Rest API using the below code. Simply put this code in your function.php file
/* Route For api */
add_action( 'rest_api_init', function () {
register_rest_route('wp/v2', 'test', array(
'methods' => array('GET', 'POST'),
'callback' => 'test',
));
} );
And then simply create a callback function test and put your stuff in to that function
function test(){
// put your stuff here
}
Related Posts:
- search blog posts by author first name and or last name
- Optimal WP Web App Backend for mobile app development
- How to display all posts divided/ordered by post date? [closed]
- Why Query is returning empty array?
- How do I extract just the post ID of the first item in whatever WP_Query returns?
- Show post content and title in diferent divs using WP_Query using a loop
- Why are my paginated posts always returning the same results?
- Ignore latest two posts
- Is it possible to use WP_Query to only pull posts with attachments?
- Show posts by author of membership level (Paid Membership Pro)
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- meta_value timestamp older than now
- Every second post different class in blog view
- Loop doesn’t exclude the specified category in home page
- Get posts with multiple categories
- Do not show children of a category
- Display posts of specific category term
- Print out last 3 blogposts
- why the same code got different results when using query_posts in functions.php and index.php
- Query posts by Author and/or by Tag
- Query for first 3 posts to change the look and feel
- How to get posts published on the latest date?
- Why posts array is empty?
- Can’t understand why sometimes a [caption] field appears
- Page and post loop same template
- Getting featured image with PHP and not javascript from wordpress api _embed [closed]
- Getting blog pagination to work on page set as front page
- How to group only VISIBLE posts? [closed]
- How to check in functions.php if there is data in a WP_Query?
- Shortcode with ‘year’ parameter
- Show metabox value last post excerpt, title and link
- Creating a WordPress Post via REST API – HTML or Markdown?
- How to get post with associated categories and tags names instead of ids with rest api?
- On what hook can I get the queried object’s final state?
- unique post in “$args” of wp_query display more than one post
- What date to use as a post date? date_gmt or modified_date_gmt
- Display current post position in Elementor Posts widget
- Why in my query is display two title?
- Migrate posts from category and sub-category via SQL
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- wp_query with ajax
- How to give classname to post if post has no content?
- WP_Query: Show 10 posts in date order, first three random
- How can I insert a new markup element after 4 posts automatically? [closed]
- Exclude some posts from displaying in wp_query based on some condition
- posts_per_page returning only one post
- If no posts exist for current day and month, show the next available day of posts
- WordPress Loop: How to display recent posts in multiple divs
- Random posts that always include a particular post?
- Need to know custom code to display random and most viewed posts in wordpress posts and pages
- Related Posts function not working
- How to retrieve certain number of images from a wordpress post?
- WordPress post filter menu
- How to display post list in a table layout (multiple queries in single loop)
- Conflict array_splice on loop and query in widget
- Not all posts showing in query
- how to handle the loop using filling bootstrap grid structure?
- Get all custom posts with a certain taxonomy
- WP_Query custom field pass the post id
- How to convert query sql to shortcode in wordpress?
- Link to date_query results in WordPress
- wp_query if have posts show date but not in loop
- Use posts_where to exclude posts ids from wp_query
- Query function not executed between element [closed]
- Custom WP_Query not working correctly
- Echo the number of posts being displayed
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- WordPress query portfolio posts
- Current and next month posts
- WP_Query of Category Not Showing First Post
- Get latest author posts inside the loop
- Limiting post list by taxonomy
- Why does WordPress search returns same number of results for every search query?
- Creating a related posts section in wordpress inside a default post
- Same post appears in related Posts?
- How to display WP Query filters?
- Finding a post’s slug
- Display 3 posts with different HTML markup using a loop
- Sidebar limiting to 10 posts?
- Change content off every sixth element
- Is there a function to get post info for any publish_status by post ID?
- How Can I Always Display A Particular Post First Using WP_Query?
- Filter out posts based on a certain post_meta on the WordPress REST API
- WP_Query get posts in custom database table [duplicate]
- WP query taxonomy optimization
- Delete Post but retain image of post [WP REST API]
- Pull in posts using post meta for REST API
- Override WordPress core post-template.php block template
- Rest API Paginate until all posts are imported
- How to show multiple posts thumbnail, title and date in widget
- How do I display main query posts in random order using add_filter
- Add a field in my rest api
- WP_Query outputs wrong post in custom post type
- WordPress Query – Display 5 posts (same post type), each from a given tag
- While loop in functions.php outputting the_title() of each post on frontpage
- how to show comments only author which send own posts in wordpress
- Group first, 2nd, 3rd, etc posts by category terms
- Manipulated offset and pagination, can’t display last post anymore
- Show posts from two specific category in WP_Query
- Why sorting posts doesn’t work properly?