I'm struggling with https://github.com/WP-API/WP-API I'm trying to add a custom post type with a custom taxonomy called listing_categy: Request this endpoint:
http://example.com/subfolder/wp-json/taxonomies/listing_categy/terms
gives me the following:
[
{
"ID": 9,
"name": "buying",
"slug": "buying-2",
"description": "",
"parent": null,
"count": 1,
"link": "http:\/\/example.com\/subfolder\/listing_categy\/buying-2\/",
"meta": {
"links": {
"collection": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms",
"self": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms\/7"
}
}
},
{
"ID": 10,
"name": "selling",
"slug": "selling-2",
"description": "",
"parent": null,
"count": 0,
"link": "http:\/\/example.com\/subfolder\/listing_categy\/selling-2\/",
"meta": {
"links": {
"collection": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms",
"self": "http:\/\/example.com\/subfolder\/wp-json\/taxonomies\/listing_categy\/terms\/8"
}
}
}
]
The php file that handles the wiring is https://github.com/WP-API/WP-API/blob/master/lib/class-wp-json-posts.php :
public function new_post( $data ) {
unset( $data['ID'] );
$result = $this->insert_post( $data );
if ( $result instanceof WP_Error ) {
return $result;
}
$response = json_ensure_response( $this->get_post( $result ) );
$response->set_status( 201 );
$response->header( 'Location', json_url( '/posts/' . $result ) );
return $response;
}
I tried sending json to / posts and it works fine for all bars ....
I tried all of the following: this:
"title": $scope.listobject.listname, "status": "publish", "slug": "selling","type": "listing", "post_meta": $scope.dataform, "terms": { "listing_categy": [9] }
this:
"title": $scope.listobject.listname, "status": "publish", "slug": "selling","type": "listing", "post_meta": $scope.dataform, "terms": { "listing_categy": [ {"ID": 9 } ]}
this:
"title": $scope.listobject.listname, "status": "publish", "slug": "selling","type": "listing", "post_meta": $scope.dataform, "terms": { "listing_categy": [9, 10 ] }
It:
"terms_names": { "listing_categy": ["selling", "buying"] }
the documentation is terrible