Last active
August 18, 2018 08:58
-
-
Save abrudtkuhl/335b7a2abe7a45c7316a to your computer and use it in GitHub Desktop.
Using WordPressSharp To Publish A Post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a new Post in WordPress | |
var post = new Post | |
{ | |
PostType = "post", // "post" or "page" | |
Title = "Using WordPressSharp", | |
Content = "WordPressSharp is a C# utility for interfacing with the WordPress XML-RPC API", | |
PublishDateTime = DateTime.Now, | |
Status = "publish" // "draft" or "publish" | |
}; | |
var customFields = new[] | |
{ | |
new CustomField | |
{ | |
Key= "my_custom_field", Value="My Custom Value" | |
}, | |
new CustomField | |
{ | |
Key = "another_custom_field", Value = "Yet another" | |
} | |
}; | |
post.CustomFields = customFields; | |
using (var client = new WordPressClient(new WordPressSiteConfig { | |
BaseUrl = "http://brudtkuhl.com", | |
BlogId = 1, | |
Username = "admin", | |
Password = "password" | |
}) | |
var id = client.NewPost(post); | |
) |
what about advance custom field repeater fields? it's a Multi-dimensional array.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi friend!
How can I add tags in a new post ?