• Hello,

    I am working on a wordpress website.now want the app for that.I have install WP REST API plugin version 1.2.2 and write my own api function.

    My API = https://192.168.1.8:8090/infinitydemo/wp-json/showposts?author=1

    function showposts()
    {
    $author = $_GET[‘author’];
    echo $author;
    $posts_array = array();

    $args = array(“post_type” => “post”, “orderby” => “date”, “order” => “DESC”, “post_status” => “publish”, “post_author” => $author);

    $posts = new WP_Query($args);
    if(!empty($posts)){
    $post_array = array(get_the_title(), get_the_permalink(), get_the_date(), get_the_content(), wp_get_attachment_url(get_post_thumbnail_id()));
    array_push($posts_array, $post_array);

    $success = array(“Message” => Success,”Response” => $posts_array);
    }else{
    $success = array(“Message” => Error,”Response” => $posts_array); }
    echo json_encode($success);

    exit(0);
    }

    but it showing
    output :
    [{“code”:”json_no_route”,”message”:”No route was found matching the URL and request method”}]

    How can I can correct this ?
    waiting for reply

  • The topic ‘How to write our own api in WP API Plugin?’ is closed to new replies.