Skip to content

Instantly share code, notes, and snippets.

@abrudtkuhl
Last active August 18, 2018 08:58
Show Gist options
  • Save abrudtkuhl/335b7a2abe7a45c7316a to your computer and use it in GitHub Desktop.
Save abrudtkuhl/335b7a2abe7a45c7316a to your computer and use it in GitHub Desktop.
Using WordPressSharp To Publish A Post
// 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);
)
@JonathanParser
Copy link

Hi friend!
How can I add tags in a new post ?

@mohammad983
Copy link

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