Closed e-ticaretim closed 5 years ago
I'm experiencing the same problems. If I try to generate a post with a post type other than "post", the generated post will have the "post" type anyway. Same goes if I try to update a post to another post type.
Hi all! To create post of custom post type you should do 2 things
var post = new Post()
{
Title = new Title("Title 1"),
Content = new Content("Content PostCreate"),
Type = "portfolio" //you custom post type
};
//change portfolio to your custom post type
var createdPost = await _clientAuth.CustomRequest.Create<Post, Post>("wp/v2/portfolio",post);
@ThomasPe may be we can add a wrapper for this scenario. Also I added a wiki page https://github.com/wp-net/WordPressPCL/wiki/Create-post-with-custom-type
Thanks @polushinmk ! It worked like a charm.
As a help for those who use this library in vb.net and 'll come here seeking for help, here's the correct vb.net syntax :
Dim createPost = Await client.CustomRequest.Create(Of Post, Post)("wp/v2/portfolio", newPost)
How to use post type. I'm creating Post, but post type assigns it as post by default?