1. Go to this page and download the library: Download hanamura/wp-model library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hanamura / wp-model example snippets
$post = new WPModel\Post($post_id);
// same properties of WP_Post are accessible
echo $post->post_date;
echo $post->post_title;
echo $post->post_mime_type;
$post = new WPModel\Post($post_id);
echo $post->permalink;
$post = new WPModel\Post(0);
$post->exists; // => false
$post = new WPModel\Post($post_id);
$post->hasChild($child_post);
$post = new WPModel\Post($post_id);
$post->matchMimeType('image/jpeg');
// create by constructor
$term = new WPModel\Term($term_id, 'custom_taxonomy');
// get from WPModel\Post
$post = new WPModel\Post($post_id);
$terms = $post->terms(array(
'taxonomy' => 'custom_taxonomy'
));
// current user
$user = new WPModel\User();
// specify user id
$user = new WPModel\User($user_id);
// same properties of WP_User are accessible
echo $user->user_email;
echo $user->user_login;
echo $user->first_name;
$user = new WPModel\User();
// get meta value
echo $user->meta->rich_editing;
// set meta value
$user->meta->rich_editing = 'false';
$post = new WPModel\User();
$post->exists; // => true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.