I like to learn some of WP automation. The WP get inbound http request to site url and the question is how to create a publication based on post (or get) data structure? How can maintain eventhandler for this and take string from the array of $_POST? to make all of this
wp_insert_post( array(
'post_title' => $new_post_title,
'post_content' => $new_post_content,
'post_status' => ,
'post_author' => ID,
'post_date' => $new_post_date,
'post_category' => $new_post_category,
'post_type' => ,
));
and get a new post in blog
As a general note, there’s the http-api (you’ve already used it to tag your question) that has an archive.
WP HTTP API
Here’s a list of “How to”-answers about the HTTP API basics
Post Data
Yes, you just use
wp_insert_post()
and similar API functions to do this.Authors: Important to note is, that every post will need a user. You can try funny stuff like using
-1
, etc. but all this won’t bring any fun stuff, instead you’ll find yourself in lots of trouble. That’s why I created “The SysBot”-Plugin – you can grab and use it for free. It’s OS.Meta Data: Here’s a pretty short and simple answer that will you guide you around this.
Another solution
As I’m currently working on something like this myself, here’s the idea: Create your own WordPress importer. Here’s the basic how-to with an already prepared plugin base:
This is the
bootstrap.class.php
file (or if you prefer WP naming conventions, name itclass-bootstrap.php
). It registers the importer and loads it.Here we got the
importer.class.php
file, that resides in the same directory. It holds the importer class that extends the default WordPress importer. You simply have to fill in your post insertion and are happy to go. Note: Write a parser function as well to prepare your data before inserting. Then write another method to sanitize the data.