PHP XML-RPC. Who will show a live example of posting in Wordpress with categories and a couple of tags, as a result should be shown the identifier of the new record, in general, a classic?
thank
I use this code:
require_once ('IXR_Library.php'); $client = new IXR_Client('http://my_blog.com/xmlrpc.php'); $client->timeout = 60000; $requestData[0] = 0; //id Π±Π»ΠΎΠ³Π° $requestData[1] = 'admin'; //ΠΈΠΌΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ $requestData[2] = 'pass'; //ΠΏΠ°ΡΠΎΠ»Ρ $post = array(); $post['post_title'] = 'New Post'; $post['post_excerpt'] = 'Short description'; $post['post_content'] = 'This story about ...'; $post['post_status'] = 'draft'; $post['post_type'] = 'my_custom_post_type'; //ΡΠΈΠΏ ΠΏΠΎΡΡΠ° $post['post_date'] = date('Ymd H:i:s'); $post['post_modified'] = date('Ymd H:i:s'); //ΡΠΎΡΠΌΠΈΡΡΠ΅ΠΌ ΠΌΠ°ΡΡΠΈΠ² Ρ ΡΠ΅ΡΠΌΠΈΠ½Π°ΠΌΠΈ ΡΠ°ΠΊΡΠΎΠ½ΠΎΠΌΠΈΠΉ $terms = array(); $terms['taxonomy_1'][] = (int)$term['term_id_1']; $terms['taxonomy_1'][] = (int)$term['term_id_2']; $terms['taxonomy_2'][] = (int)$term['term_id_3']; $terms['taxonomy_3'][] = (int)$term['term_id_4']; $post['tax_input'] = $terms; $requestData[3] = $post; if (!$client->query('my.publish_post', $requestData)) { echo 'Publish Post error: '.$client->getErrorMessage(); return; } $publishedPost = $client->getResponse();
Source: https://ru.stackoverflow.com/questions/98521/
All Articles