Seach

wordpress as webservice

dowload and install
https://wordpress.org/plugins/json-api/
goto plugin->json api ->controller create gallery.php

<?php
/*
Controller name: Gallery
Controller description: Retrieve gallary posts
*/
class JSON_API_Gallery_Controller {

 function gallery_posts()
 {
  $args=array
  (
  "post_type"=>"gallery",
  "post_status"=>"publish",
  "orderby"=>"ID"
  );
  $posts=get_posts($args);
  $json=array();
if(count($posts)!=0)
{
$json['status']=array('ok');
 
  foreach($posts as $key=>$record)
  {
  $youtube=get_post_meta($record->ID,'youtube',true);
$json["result"][]=array("title"=>$record->post_title,'content'=>$record->post_content,'url'=>$youtube);
  }
  return $json;
  }
  else
  {
  return $json['status']=array('failed');;
  }
 
 
 }

}
this fetch gallery named post data
jquery for fetch the service

 function gallery_load()
{
    $.ajax(
            {
                url: "http://faithsolution.byethost17.com.in/?json=gallery.gallery_posts",
        type: "POST",
        dataType: "jsonp",
        headers: {"'Access-Control-Allow-Origin": "*"},
        beforeSend: function(xhr) {
        }, complete: function(jqXHR, textStatus) {
        }, success: function(data)
        {
            if (data.status == "ok")
            {
                for (i = 0; i < Object.keys(data.result).length; i++)
                {
                   
                }
            }
            else
            {
            }
        }, error: function(jr, textstatus)
        {
            console.log(textstatus);
        }});
}