如何以编程方式将文章发布到Wordpress?

时间:2009-12-18 08:40:35

标签: wordpress plugins wordpress-theming

想知道是否有一种方法可以直接从您自己的PHP代码向Wordpress发布文章。我想从我的php页面发布我自己的独立wordpress,它应该调用托管的wordpress 2.8.6版本并发布带有图像的文章(自动创建缩略图)。有可能吗?

3 个答案:

答案 0 :(得分:3)

global $user_ID;
$post = array();
$post['post_type']    = 'post';
$post['post_content'] = 'Put your post content here';
$post['post_author']  = $user_ID;
$post['post_status']  = 'publish';
$post['post_title']   = 'Your Post Title';
$postid = wp_insert_post ($post);
if ($postid == 0) 
  echo 'Oops!';
else
  echo 'Snazzy!';

来自:http://wordpress.org/support/topic/254439

答案 1 :(得分:1)

作为PHP脚本的替代方案,如果您觉得这很有趣,可以使用Yahoo这样做,这里是链接:

http://wordpressmodder.org/how-to-post-to-your-wordpress-site-directly-from-yahoo-mail-570.html

答案 2 :(得分:0)

使用Wordpress现有的XMLRPC函数:Post on your WordPress blog using PHP