Dealing with Custom Taxonomies in the WP-API

I have recently started working on a mobile app for a WordPress site that relies heavily on custom taxonomies.

The app needs to pull in posts from WordPress through the WP-API, and allow user filtering based on taxonomy. This requires some special handling, since custom taxonomies don’t appear in the WP-API by default.

What’s a custom taxonomy?

Taxonomies are for categorization. An example of a taxonomy is a category or a post tag.

For example, this post is in the ‘category’ of ‘wp-api.’ We can have lots of terms like wp-api, tutorial, blog, or personal under the name ‘category.’ A custom taxonomy could be swapping the word ‘category’ for something like ‘device.’ So we could have terms like ‘iPhone’, ‘Android’, and ‘Windows’ under our ‘device’ taxonomy.

For more on custom taxonomies, check out these references.

Creating custom taxonomies

Creating custom taxonomies uses the register taxonomy function. It’s similar to creating a custom post type, and just like a CPT, it won’t show up the WP-API unless we add show_in_rest = true.

To create a custom taxonomy that shows up in the WP-API, we could do something like this:

// hook into the init action and call create_book_taxonomies when it fires
add_action( 'init', 'create_book_taxonomies', 0 );

// create two taxonomies, genres and writers for the post type "book"
function create_book_taxonomies() {
	// Add new taxonomy, make it hierarchical (like categories)
	$labels = array(
		'name'              => _x( 'Genres', 'taxonomy general name' ),
		// more labels here...

	$args = array(
		'hierarchical'      => true,
		'labels'            => $labels,
		'show_ui'           => true,
                'show_in_rest'      => true,
		'show_admin_column' => true,
		'query_var'         => true,
		'rewrite'           => array( 'slug' => 'genre' ),

	register_taxonomy( 'genre', array( 'book' ), $args );

The main thing to notice is the ‘show_in_rest’ argument, set to true.

Adding current taxonomies to the WP-API

If the taxonomy has already been created, or you don’t have access to the registration function, you can add the show_in_rest argument like this.

For a single taxonomy:

function sb_add_tax_to_api() {
    $mytax = get_taxonomy( 'genre' );
    $mytax->show_in_rest = true;
add_action( 'init', 'sb_add_tax_to_api', 30 );

For multiple taxonomies, something like this:

function sb_add_taxes_to_api() {
    $taxonomies = get_taxonomies( '', 'objects' );
    foreach( $taxonomies as $taxonomy ) {
	    $taxonomy->show_in_rest = true;
add_action( 'init', 'sb_add_taxes_to_api', 30 );

WP-API endpoint for custom taxonomies

After you’ve added your custom taxonomy to the WP-API using show_in_rest, you can navigate to the taxonomies or terms endpoint to see it in action.

For example, using the example of ‘genre’ from above, we could go to to see all of our genres. Let’s say we had a genre called ‘fiction’ with an ID of 212. To see information about only the fiction genre, we could visit

If we just wanted the structural information about the taxonomy, we could visit

If we wanted to get only the posts in a certain term (like fiction), we could make a GET request to[genre]=fiction. You could do the same for a custom post type (assuming you’ve added show_in_rest = true for the post type) by using the CPT’s endpoint:[genre]=fiction

I hope that helps! Let me know if you have any additional tips or questions in the comments.

4 Ways to Make Your Ionic App Feel Native


Recent developments in the hybrid world are blurring the lines between hybrid and native.

You can now use native transitions and native scrolling, along with a fast framework like Ionic. In many cases, it’s impossible to tell any difference between hybrid and native, since many fully native apps use WebViews.

The exciting thing is that hybrid apps are improving at breakneck speed, and it’s never been a better time to be in this field. There are 4 things that can drastically improve your apps and make them feel more native, let’s look at them now.

Continue reading

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 To get a specific type, I could send my request to

There have been some pretty big changes in version 2, which is the version that will (hopefully) be in WordPress core sometime soon.

Custom post types are now hidden from the API by default. I can see why they did this, many themes and plugins added post types that they never intended to be public. Making those public would cause more problems than it would solve.

However, that now means we can’t just add the ‘type’ flag to our request, and expect to get post types back.

Continue reading

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 an external client like a mobile app. I haven’t dug into OAuth yet, but it’s documented a little bit here.

We are using the Ionic Framework for the WP-App Project, which is based on AngularJS. Basic authentication requires sending the username and password, base64 encoded, in the request header. Here’s what that looks like.

Continue reading

The WP-App Project


Today I’m excited to announce the WP-App Project: a free, open-source mobile app for WordPress site management.

The idea is to create a customizable mobile app for WordPress site owners to manage their posts, pages, comments, media, etc.

What’s that you say, a WordPress app already exists? Ah, but not like this. No sir, not like this.

With this app, you’ll be able to write a simple plugin that adds a section to the app. Let’s say you are the developer of a successful forms plugin. You will be able to create an add-on for your product that adds management of form entries to this app, without touching any app code. An Ecommerce plugin developer could make a plugin that adds sales statistics to the app (with authentication of course).

Or say you just created a very custom site for a client, and they don’t use blog posts at all. You can remove the Posts page from the app, and instead add your custom CPTs.

This app uses the WP-API, which is very easy to interact with. It will be free and open-source, and I would love to have you help with the project.

This app is for you, it’s not for me. It’s not a product, and it’s not for sale. It’s so you can have a mobile app in your hands to hack and customize, without submitting anything to the app stores, or writing app code. Work with me to make this the coolest WordPress app ever.

This is not an AppPresser product, it’s totally open-source and free, but I wrote more about it on the AppPresser blog.

I need your help to make this app a reality, please read the post on the AppPresser blog to find out how you can help.


The Most Important Thing a Founder Does


Most companies start when someone has an idea, and they start making something: a product, a consultancy, a SaaS app, or whatever.

In the early days, the founder is really involved in making the product. If you are a technical founder, you write a lot of code, build your website, setup email marketing and other tools, etc.

As your company grows, your role changes, and you have to take off your “maker” hat to work on building your company. This is a difficult transition as a technical founder, because the only thing you know is making products.

Continue reading

The Minimum Viable Product

Minimum Viable Product

“Real artists ship.” –Steve Jobs

“If you’re not embarrassed when you ship your first version you waited too long.” –Matt Mullenweg

You’ve probably heard of an MVP, it stands for Minimum Viable Product.

The term was popularized by Eric Ries, It means that you should ship when you reach minimum viability, not a moment before or after that.

You shouldn’t take MVP to mean that you should ship a piece of crap. The emphasis in MVP is on viable, not on minimum.

Continue reading

Things you’ll never hear product developers say


On Overnight Success

“The first time I tried to build a product it was a staggering success, guess I just got lucky.”

“If you build it, they will come is totally true.”

On SaaS

“It’s so easy to make money with SaaS, you just set it and forget it.”

On Agencies Moving to Products

“Adding a successful product line to my Agency was easy, I had plenty of free time and the early lack of revenue totally made sense.”

On Version 1

“I love all of the development decisions I made for version 1.”

“I wouldn’t change a single line of code if I had to build it all over again.”

“We reached product/market fit right away, we didn’t even have to make any changes.”

On Support

“Support doesn’t really take that much time out of my day.”

“Support is my favorite part of building products.”

On Marketing

“I’ve had great luck with AdWords.”

“I wish we hadn’t spent so much time blogging.”

On Features

“I’m so glad I added in all those features early on, it makes my life easier.”

Add yours to the comments :)

The WordPress Theme Business, Then and Now

WordPress theme business

I’ve been selling products for 5 years now, starting with premium WordPress themes.

I now have a plugin business and a SaaS product. I’ve learned a lot, this post is basically everything that worked and didn’t work for my theme business, and where I see the theme market today.

A brief history of premium themes

Matt Mullenweg forked b2 to create the first version of WordPress in 2003. Around 2007-08 the first premium theme companies started popping up. (There’s a nice history of premium themes here.)

One of the first was Studiopress, founded by Brian Gardner. Studiopress quickly escalated into six figures per month, and other theme businesses such as Press75 found fast success as well, and the theme gold rush started.

Lots more players jumped into the market over the next several years, and that trend has continued. Some market leaders emerged (Woothemes, StudioPress, Elegant Themes), and new distribution has changed the game (Themeforest).

Fast forward to today. The market is incredibly saturated, prices have dropped, and theme quality/bloat has become an issue.

Continue reading