Using WordPressSharp To Publish A Post
January 26, 2015
developmentThis is a brief intro to using WordPressSharp to publish a post with C# via the WordPress XML-RPC API.
A few notes... the 'PostType' property of the Post class can be set to either "post" or "page" depending on which WordPress type you want to publish.
And the 'Status' property can be set to either "publish" or "draft" depending on whether you want to publish your new post/page right away or not.
In the future I'd like to make these enums or something extendable. But WordPress has them as strings so you can define new ones (ie Custom Post Types) on your own. Keep in mind this class is merely a simple example. In most cases you might want this in a service layer where you can inject the WordPressSiteConfig class as you need it.
Update: 8/11/2017 There have been a lot of questions about how to add tags and categories to a post since this example contains none. First off - the tag/category/custom taxonomy needs to exist first so you have to create it. Then attach it to the Terms[] collection on the post when creating it.
Here's an example: https://github.com/abrudtkuhl/WordPressSharp/issues/68#issuecomment-321923121 Also - the WordPressSharp nuget package has been updated to the latest and greatest.
Active Projects
Here are some of the projects I am currently working on. Some are side projects, some are client projects, and some are just for fun. I like to build things and I like to share what I learn along the way. If you have any questions about any of these projects, feel free to reach out.
🏗️ JSONL Tools
I am working on a set of tools to help me work with JSONL. JSONL is a simple format for working with JSON data. I am working on a set of tools to help me work with JSONL data. I will use these tools to help me work with my own data as well as help me build my own APIs. Read more about this project in my blog post about building JSONL Tools.
🤖 Make Storytime
Personalized children's stories generated by AI. This is an app I am building with my kids.
📠 Fax Online
Yea, I know. But there is a long tail for everything and believe it or not there was an underserved market for people that need to send a fax online. Some people (like me!) just need to send a one time fax.
Read more about this micro Saas project in a blog post about building an online fax service.
🥑 Free URL Indexer
Free URL Indexer is a free tool to help you index your backlinks and get them into Google faster. It's a simple tool that I built to help me with my own SEO efforts and I decided to share it with the world. It's a free tool and I don't even ask for your email address. Just paste in your URL and click the button.
👉 See all projects