Skip to content

Commit d94ea44

Browse files
committed
Added functionality to get custom post types
1 parent 7a06c49 commit d94ea44

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/main/java/com/afrozaar/wordpress/wpapi/v2/Client.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,14 @@ public PostMeta createMeta(Long postId, String key, String value) {
335335
return exchange.getBody();
336336
}
337337

338+
@Override
339+
public PostMeta createCustomPostMeta(Long postId, String key, String value, String customPostTypeName) {
340+
final Map<String, String> body = ImmutableMap.of(META_KEY, key, META_VALUE, value);
341+
final ResponseEntity<PostMeta> exchange = doExchange1(Request.CUSTOM_POST_METAS, HttpMethod.POST, PostMeta.class, forExpand(customPostTypeName, postId), null, body,
342+
MediaType.APPLICATION_JSON);
343+
return exchange.getBody();
344+
}
345+
338346
@Override
339347
public List<PostMeta> getPostMetas(Long postId) {
340348
final ResponseEntity<PostMeta[]> exchange = doExchange1(Request.METAS, HttpMethod.GET, PostMeta[].class, forExpand(postId), null, null);

src/main/java/com/afrozaar/wordpress/wpapi/v2/api/PostMetas.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ public interface PostMetas {
1111

1212
PostMeta createMeta(Long postId, String key, String value);
1313

14+
PostMeta createCustomPostMeta(Long postId, String key, String value, String customPostTypeName);
15+
1416
List<PostMeta> getPostMetas(Long postId);
1517

1618
PostMeta getPostMeta(Long postId, Long metaId);

0 commit comments

Comments
 (0)