WP::API::Post - An interface for WordPress post objects
version 0.01
my $post = $api->post()->create( post_title => 'Foo', post_date_gmt => $dt, post_content => 'This is the body', post_author => 42, ); print $post->post_modified_gmt()->date(); my $other_post = $api->post()->new( post_id => 99 ); print $other_post->post_title();
This class provides methods for creating new posts and fetching data about existing posts.
See the WordPress API documentation at http://codex.wordpress.org/XML-RPC_WordPress_API for more details on what all of the fields mean.
This class provides the following methods:
This method constructs a new post object based on data from the WordPress server. The only accepted parameter is a post_id, which is required.
post_id
This method creates a new post on the WordPress server. It accepts a hash of all the attribute values listed below. See the WordPress API docs for a list of required fields. Haha, just kidding, they don't tell you, so you'll just have to guess.
For date fields, you can pass a DateTime object or an ISO8601 string (e.g. "20130721T20:59:52").
Returns the post's type, something like "post", "page", etc.
Returns the post's status, something like 'publish', 'draft', etc.
Returns the post's title.
Returns the user_id of the post's author.
Returns the post's excerpt if it has one, undef otherwise.
undef
Returns the post's body.
Returns the post's creation date and time as a DateTime object in the UTC time zone.
Returns the post's creation date and time as a DateTime object in the server's local time zone.
Returns the post's last modification date and time as a DateTime object in the UTC time zone.
Returns the post's last modification date and time as a DateTime object in the server's local time zone.
Returns the post's format.
Returns the post's name.
Returns the post's password if it has one, undef otherwise.
Returns the post's comment status, something like "closed" or "open".
Returns the post's trackback status, something like "closed" or "open".
Returns a boolean indicating whether the post is sticky.
Returns a hashref of information about the post's featured image. See the WordPress API docs for details.
Note that this might become a real object in the future.
Returns the post_id of the post's parent or 0 if it doesn't have one.
Returns the post's MIME type if it has one, undef otherwise.
Returns a URI object for the post's URI.
Returns a URI object for the post's GUID URI.
Returns the post's menu order.
Returns an array reference of hash references, each of which is a custom field name and value. See the WordPress API docs for more details.
Note that this might become a real object or arrayref of objects in the future.
Returns an array reference of hash references, each of which is a taxonomy term. See the WordPress API docs for more details.
Returns a hash reference of data about the post's enclosure. See the WordPress API for details.
Dave Rolsky <autarch@urth.org>
This software is Copyright (c) 2013 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
To install WP::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WP::API
CPAN shell
perl -MCPAN -e shell install WP::API
For more information on module installation, please visit the detailed CPAN module installation guide.