NAME

WP::API::Post - An interface for WordPress post objects

VERSION

version 0.01

SYNOPSIS

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();

DESCRIPTION

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.

METHODS

This class provides the following methods:

$api->post()->new( post_id => $value )

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.

$api->post()->create(...)

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").

$post->post_type()

Returns the post's type, something like "post", "page", etc.

$post->post_status()

Returns the post's status, something like 'publish', 'draft', etc.

$post->post_title()

Returns the post's title.

$post->post_author()

Returns the user_id of the post's author.

$post->post_excerpt()

Returns the post's excerpt if it has one, undef otherwise.

$post->post_content()

Returns the post's body.

$post->post_date_gmt()

Returns the post's creation date and time as a DateTime object in the UTC time zone.

$post->post_date()

Returns the post's creation date and time as a DateTime object in the server's local time zone.

$post->post_modified_gmt()

Returns the post's last modification date and time as a DateTime object in the UTC time zone.

$post->post_modified()

Returns the post's last modification date and time as a DateTime object in the server's local time zone.

$post->post_format()

Returns the post's format.

$post->post_name()

Returns the post's name.

$post->post_password()

Returns the post's password if it has one, undef otherwise.

$post->comment_status()

Returns the post's comment status, something like "closed" or "open".

$post->ping_status()

Returns the post's trackback status, something like "closed" or "open".

$post->sticky()

Returns a boolean indicating whether the post is sticky.

$post->post_thumbnail()

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.

$post->post_parent()

Returns the post_id of the post's parent or 0 if it doesn't have one.

$post->mime_type()

Returns the post's MIME type if it has one, undef otherwise.

$post->link()

Returns a URI object for the post's URI.

$post->guid()

Returns a URI object for the post's GUID URI.

$post->menu_order()

Returns the post's menu order.

$post->custom_fields()

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.

$post->terms()

Returns an array reference of hash references, each of which is a taxonomy term. See the WordPress API docs for more details.

Note that this might become a real object or arrayref of objects in the future.

$post->enclosure()

Returns a hash reference of data about the post's enclosure. See the WordPress API for details.

Note that this might become a real object in the future.

AUTHOR

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2013 by Dave Rolsky.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)