Get Attached Media For A Certain Post With REST API

UPDATED 03/09/2017: According to the API documentation, we can now use endpoint "wp-json/wp/v2/media?parent=POST_ID" to get the attachments to a certain post without an extra filter. For example: https://1fix.io/wp-json/wp/v2/media?parent=1645.

When trying to get attached media for a certain post in WordPress with JSON REST API, I thought it would be something like:

URL/wp-json/posts?filter[post_parent]=<id>&filter[post_type]=attachment

But it didn’t work. So I turned to wp-api.org to find the solution.

Read more

Using AngularJS and JSON API in Your WordPress Theme

This post is based on a tutorial video from WordPress.tv – Eric Wolfe: Building a WordPress Theme Using AngularJS.

This is the first post of a series about building WordPress themes with AngularJS and WP REST API (WP API).

AngularJS Logo

I tried AngularJs a while ago on Code School (free online course) and found it very impressive. Since my work is mostly based on WordPress in these days, learning how to make AngularJS and JSON API play nicely together, become my new hobby in the weekend.

When starting learn something new, I always start from Google. By just googling some keywords or phrases, I’ll get the most comprehensive resources on the topic I’m ready to dive in. To dig out really high quality stuff, I’ll use long tail keywords to narrow down the results. Luckily in this case, when googling “WordPress JSON API+AngularJS” there are no overwhelming results for me to sort out. I could learn on my own pace and share some tricks here to help newcomers.

Before we get started, if you’d like to know why AngularJS are popular these days, and why WordPress is good to serve as backend for websites, you could check this slide shared by Eric W. Greene, for the time of this writing, it takes the second spot when I google for “WordPress JSON API+AngularJS”.

Even if you have no experience in AngularJS, as long as you’re comfortable with coding, now you can open your favorite code editor and work with me.

Read more