Some WP-API Tips for WordPress 4.7+

Now that the WP-API is in core, here are some useful tips for you. Filtering Posts Filtering posts was a bit confusing for me at first, because the documentation seems to suggest you would visit an endpoint like /posts/category/40 to get posts from a certain category. Instead, you are supposed to use arguments in your […]

Working with Custom Post Types in WP-API v2

If you worked with the first version of the WP-API, you know that getting custom post types was really easy. To get all posts, I could send a GET request to http://scottbolinger.com/wp-json/posts. To get a specific type, I could send my request to http://scottbolinger.com/wp-json/posts?type=event. There have been some pretty big changes in version 2, which […]

Basic Authentication with the WP-API (v2) and AngularJS

Working on the WP-App Project, we need to use authentication to do certain things in the app. Deleting/approving comments, or listing users for example. Basic Authentication is handy for testing code, but it should only be used in development, since you send the user/pass with every request. For production, you’ll want to use OAuth from […]

Protocol Relative URLs

Ever use a script that had a url without the http like this? <script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script> I always wondered what that was about. Turns out it allows your browser to download the resource through http or https, which gets rid of any pesky warning messages about “Non-secure items” when viewing an https page.