Download the PHP package hokoo/wppostable without Composer
On this page you can find all versions of the php package hokoo/wppostable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hokoo/wppostable
More information about hokoo/wppostable
Files in hokoo/wppostable
Package wppostable
Short Description Library provides a functionality for associating your classes with WordPress class WP_Post.
License MIT
Informations about the package wppostable
What is wpPostAble
Library provides a functionality for associating your models with WordPress WP_Post model. Once you create the instance, wpPostAble creates the WP_Post object and stores it in your instance.
You can manage your instance with such methods as
$instance->getTitle();
$instance->setTitle();
$instance->getMetaField();
$instance->setMetaField();
$instance->getStatus();
$instance->setStatus();
$instance->getPost();
$instance->getPostType();
$instance->savePost();
$instance->loadPost();
$instance->publish();
$instance->draft();
and others.
Use
$instance->getParam();
$instance->setParam();
method to manage metafields, stored inside posts
table using post_content_filtered
field.
How to use
-
Create your own class based on wpPostAble interface
-
Call
wpPostAble()
method in the beginning of the__construct()
method of your class.Pass to it two parameters
$post_type
string WP post type, associated with your class$post_id
int Post ID for existing post, or nothing for creating new post
Now you are able to use your class
Create new post
or load from existing one
Once you create an instance, wpPostAble creates new post in WordPress as a draft.
Let's try change the title
Now you have set title, and let's try to save it in database
Maybe it's time to publish?
You can do it by single line
More options you can find in the description above and in the source code.