Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Creating JSON feeds from WordPress

From: jQuery Mobile Web Applications

Video: Creating JSON feeds from WordPress

The difference between just building a mobile We have some information that has name and value pairs.

Creating JSON feeds from WordPress

The difference between just building a mobile webpage and the web application we're going to be building is that our web app will get information and assemble itself from data sources. It means that we're going to have to get some information. And in this video I'll start by discussing the JSON format and show you how to get data out of a word press blog ,so JSON is a format for sharing data. It's really nothing more than a text file written in a certain way. So you can see a quick example right here. We have some information that has name and value pairs.

So for example we have this name field right here. And it's in quotes, that makes it in the JSON format. And then we have a value my name right here Ray Villalobos. And then we have a position attribute with a value of Staff Author and then we have something that is an array of element or a list of elements, and that is placed within these brackets right here, and then each of the list items is separated by commas. So that's a quick example of how a JSON looks, but it actually can get a lot more complicated because each one of these name value pairs can have different types of information.

So these are all pretty much text. You saw an array here, but they can also be booleans or other objects. Now, JSON is based on JavaScript objects and eventually JSON data goes into a JavaScript variable or a JavaScript object, that then you can parse with your program. And so all this information is going to go in, be inserted into a variable that you're going to manipulate. Thankfully, when you're using jQuery Mobile, you get a full copy of jQuery. And jQuery makes it super easy to read in and parse information in the JSON format.

You can access information in the JSON format from a variety of sources. And, although I'm going to show you how to do this in WordPress. You can get information from a PHP script in the JSON format. Or you can read a feed from many other different services, like YouTube, Twitter, and Flickr. And that makes it a great format for sharing information from a variety of sources. Once you get that information into your web application, you can use that data to build pages. But the first thing we need is some kind of information and if you're going to need information from a website you're going to need to have that data transferred from whatever your site is using into the the JSON format.

Now if you want to learn more about JSON make sure you check out my course JavaScript and JSON. It has a lot more information about not just JSON but JavaScript objects. So what if you have a blog and you want to convert or extract some of the data in the blog into a web application using JSON? WordPress by itself doesn't have a way of outputting JSON files, but thankfully, WordPress is very extensible, and so by adding a plugin, you can very easily add the functionality you need To export your data.

So, the plugin that I like to use is called the JSON API plugin. And you can check it out at this page. Now, it's very easy to use and if you click right here on this other note section, you can see the complete documentation. It has a very complicated and very full featured API. But basically what you do is you call your website URL and then you can add parameters like? JSON equals one and it will output the information in your blog in the JSON format.

And you can also say hey just get me the recent posts Or include other parameters like anything that's tagged with the slug banana, et cetera, et cetera. This can get very complicated, but let's go ahead and show you how you can install this on your WordPress blog. So here I am in my blog. I'm going to go to the admin section, so I'll do my blog's name, and then admin. And it may ask you to log in with your credentials, but I've been in my blog recently, so it just takes me straight to my admin page.

Now from here, you want to go to the plugins section. And from here, you want to add a new plugin. Now in here you want to search for JSON API and click on search plugins. And then click on install now. You may have to put in the credentials for your website. Once it downloads the information,you want to click on this, Activate Plugin button right here. Now that the JSON API plugin has been installed, we can use it to call our website. So if you remember, to call our website and get the JSON data, all I have to do is do iviewsource,and then question mark JSON equals one.

So when I hit return, I should see something that looks like this. Now, this may not look very friendly, but in reality, it's a JSON file. And you can grab this information from the JSON file, read it into a JavaScript variable, and start accessing anything within this data. But in order for us to understand what kind of data we receive back from our JSON feed. It's really good to use some sort of JSON editor or at least a visualizer. And so what I'm going to do is I'm going to select everything in here, I can triple click to select everything, and then I'm going to copy this into my clipboard.

Then I'm going to switch over to another web application. So this web application is called the JSON editor online And what you can do here is you can paste a raw JSON file so I'm going to grab this and delete it. And paste the information I got from the JSON API plug in. And once it's in there I can click on some of these buttons. Actually, I'm going to click on this one right here. And it will convert the data so it's at least a little bit more readable. Now what's even better is that I can hit this button and it's going to convert it into an object that is easier to read.

So we just took all this information, that is even though a little bit better organized still a little bit messy And it organized it in a way that I can easily look at and expand a little better. So from here you can see, okay, you're going to get back some sort of object. And this object is going to have a few different name and value pairs. So for example we get, status okay, count five, which tells us how many things we got back. And then, some other information. Like how many pages are in our blog.

And how many articles are in the blog, as well. Now, the interesting piece of info is this posts right here. So, we're getting five posts back from our JSON feed. We can open that up and see an array of different elements. If we open any one of these up. you'll see some additional information. So this JSON editor online is a really good visualizer that allows us to see the structure of our data. And once we start working with JSON and inputting that data using jQuery.

We're going to be able to create pages using this information.

Show transcript

This video is part of

Image for jQuery Mobile Web Applications
jQuery Mobile Web Applications

37 video lessons · 4925 viewers

Ray Villalobos
Author

 
Expand all | Collapse all
  1. 2m 59s
    1. Welcome
      58s
    2. What you should know
      1m 12s
    3. Using the exercise files
      49s
  2. 44m 29s
    1. Downloading and installing jQuery Mobile
      12m 3s
    2. Creating a page
      6m 1s
    3. Using buttons
      8m 11s
    4. Adding control groups
      5m 22s
    5. Creating a header toolbar
      7m 3s
    6. Adding icons to a footer toolbar
      5m 49s
  3. 43m 46s
    1. Creating JSON feeds from WordPress
      7m 11s
    2. Importing feeds into our application
      6m 45s
    3. Creating our page templates
      5m 18s
    4. Populating filterable list items dynamically
      10m 31s
    5. Adding thumbnails to our list items
      5m 19s
    6. Fixing potential link problems
      2m 54s
    7. Adding a more information page
      5m 48s
  4. 20m 52s
    1. Creating dynamic toolbars
      7m 49s
    2. Adding a headline to our toolbars
      3m 18s
    3. Injecting a footer
      4m 45s
    4. Highlighting the active toolbar link
      5m 0s
  5. 35m 34s
    1. Preparing pages for our feed
      4m 34s
    2. Understanding the YouTube API
      4m 58s
    3. Parsing the YouTube feed
      9m 36s
    4. Adding thumbnails and links
      6m 27s
    5. Playing our video
      5m 53s
    6. Styling our YouTube elements
      4m 6s
  6. 27m 47s
    1. Working with a feed from Flickr
      8m 38s
    2. Parsing data from the Flickr API
      9m 39s
    3. Displaying photos on a separate page
      3m 28s
    4. Styling a responsive grid
      6m 2s
  7. 27m 51s
    1. Setting up a Twitter account
      4m 32s
    2. Understanding the Twitter feed
      3m 24s
    3. Parsing data from the Twitter API
      4m 35s
    4. Styling our Twitter feeds
      3m 31s
    5. Processing Tweets through regular expressions
      6m 35s
    6. Finishing our app
      5m 14s
  8. 2m 2s
    1. Next steps
      2m 2s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed jQuery Mobile Web Applications.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.