I am pretty new in Wordpress and I am a little overwhelmed with the amount of elements and possibilities we have to build our site. So I would like some advices.

The first think I want to do is a dynamic page with a Gallery of photos.

In a nutshell: I have an API: it receives a code in the URL and gives back the array of paths for some URL photos (actually is a complex JSON response with also these elements).

My question is, can I make a page in WordPress that:

  • Have a field for inserting the code;
  • Once the code inserted, it would read the response of the API
  • Parse the response to get the path of the photos
  • Display in the screen the photos in these URL's

Which elements should I start to search?: javascript, php, some plugins REST, API?


  • The data would not be saved, everytime the page is loaded again.
  • Thepage will be accessible by anyone in the front-end.
  • The API is accessible by a simple URL with a ?code='XXXX' field in the URL.
  • The form and the display can be in the same page.

Rigth now I've been using Php in a Symfony2 framework to do the job, but as I need to put in Wordpress I migth need to make other strategies:

 public function galerieAction($code){

        $url = 'http://myapi/photos/'.$code.
        $json = file_get_contents($url);
        $pellicule = json_decode($json);

        $url = 'https://server.com/server/of/photos';

        foreach ($response->photos as $photo){
            $link = $url.$photo->path;

            echo "<img src='".$link."' />";

  • Do you want to save the results? Should only admins be able to use this form? Is this form used on the front-end? What kind of code are you putting in? Do you need to sanitize it? What form does the request need to be to the API? Is the form and display the same page? Or are there two separate areas? Can you provide code you currently use?
    – jgraup
    Nov 14, 2016 at 14:18

1 Answer 1


Make a page and assign a custom page template that includes a form which references itself in the action --- #.

Then just check the $_REQUEST for the information sent by the form.

There are several functions in the HTTP API that will help you send a request to your API and handle the request.

It doesn't look like you need anything from the REST API on your site, so don't worry about that.

If you want to go the AJAX route and not leave the page, there are several examples on how to use admin-ajax.php or admin-post.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.