Wordpress - Set post_date
I'm trying to set the post_date
of a blog post to Wordpress via XMLRPC.
I'm sending the data as a string:
$pubdate = '2010-04-08 13:46:43';
'post_date'=>$pubdate,
It appears 'post_date'
is correct?
I also found this post losely related to the issue: http://wordpress.开发者_运维技巧org/support/topic/330597
Can anyone suggest how I would post the date as: dateTime.iso8601
Have you tried this ?
$pubdate = date('c',strtotime('2010-04-08 13:46:43'));
http://www.php.net/manual/en/function.strtotime.php
http://www.php.net/manual/en/function.date.php
To post the date as a <dateTime.iso8601>
element (assuming you're using the built-in XML-RPC client within WordPress, you want to cast your date as an IXR_Date
object.
// Convert the time to an integer value for parsing.
$pubdate = strtotime( '2010-04-08 13:46:43' );
// Convert the date to the right kind of object.
$pubdate = new IXR_Date( $pubdate );
Now, when you pass your array of arguments to make the request, passing 'pub_date' => $pubdate
will create the correct XML element.
See this other answer to a similar question for more information if you want a full, working example.
精彩评论