I'm developing a wordpress plugin and I would like to create a page with JSON output with some custom db queries that I will use from javascript.
What are best practices?
I tried to use wp-api with a custom controller, but I don't need that plugin..
Maybe is better to create a custom .php file that will use wordpress objects for querying database with json output?
Thanks
I chose to create a custom .php file, I don't know if it's the better choice, but it works :)
<?php
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] = 'GET') {
require_once '../../../../wp-blog-header.php';
require_once '../includes/engine.php';
$engine = new Engine();
echo json_encode($engine->Data());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.