Skip to content

TomodomoCo/wp-api-terms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

WP-API Term/Taxonomy Support

This is a simple plugin that lets you add terms when you POST new content to the WP REST API.

Here's an example of a JSON post object (POSTed to /wp-json/posts) that will create a new post with some tags:

{
	"title": "Hello there",
	"content_raw": "My awesome content",
	"x-terms": [{
		"post_tag": {
			"terms": [
				"my_tag",
				"my_other_tag"
			]
		}
	}]
}

and a custom taxonomy:

{
	"title": "Hello there",
	"content_raw": "My awesome content",
	"x-terms": [{
		"my_taxonomy": {
			"terms": [
				"my_term"
			]
		}
	}]
}

and both at the same time:

{
	"title": "Hello there",
	"content_raw": "My awesome content",
	"x-terms": [{
		"post_tag": {
			"terms": [
				"my_tag",
				"my_other_tag"
			]
		},
		"my_taxonomy": {
			"terms": [
				"my_term"
			]
		}
	}]
}

By default, this will overwrite existing terms on a post (within the taxonomy you're working with). To only append content, use the "append" setting:

{
	"title": "Hello there",
	"content_raw": "My awesome content",
	"x-terms": [{
		"post_tag": {
			"append": "true",
			"terms": [
				"my_appended_tag"
			]
		}
	}]
}

I'm indebted to WordPress.org user WizADSL who created the original version of this plugin for categories and tags.

License

GPLv2 or later. Enjoy!

About

DEPRECATED - Support setting terms on new posts while using WP-API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages