Querying from custom table
-
Sorry but I am new to this, so I’m a little confused. I am currently trying to extend this plugin to return me data from a non WordPress table. I have created a new class file in lib, referring to the class-wp-json-posts.php as an example. So far, I’ve modified the register_routes function to take in the url that I want.
public function register_routes( $routes ) { $customer_routes = array( '/customers' => array ( array( array ( $this, 'get_customers' ) , WP_JSON_Server::READABLE ), ), ); return array_merge( $routes, $customer_routes ); }I know that I am supposed to create a customizes get_customers function to query the table that I want. But when I tested it out using the curl -i command, it gives me back “json_no_route”. What am I doing wrong? Or am I missing a step somewhere? Also, how to I accept parameters for my api call? For example: I want to have the url as http://example.com/wp-json/customers?param1=1¶m2=2 ?
Thanks.
The topic ‘Querying from custom table’ is closed to new replies.