Skip to content

webxid/wp-post-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The lib help to wrap WP instances and to cache already collected data. Also, you can implement your own method for a post instance

Install

Run composer require webxid/wp-post-wrapper

How to use

E.g. we have the next implementation: PageBlocks of a posts type and the next SimpleBlock of a post and the next Category of a post taxonomy

Factory method

You can implement a separate class for a specific post and handle custom fields as the post instance properties

Get data

To get a posts list

use WebXID\WpPostWrapper\Example\PageBlocks
use WebXID\WpPostWrapper\Example\SimpleBlock;

foreach(PageBlocks::buildPostsList() $key => $post) {
    /** @var SimpleBlock $post */
    
    // do some code
}

To build a single post instance

use WebXID\WpPostWrapper\Example\PageBlocks
use WebXID\WpPostWrapper\Example\SimpleBlock;

/** @var SimpleBlock $post */
$post = PageBlocks::itemFactory(get_post());

To build a taxonomy instance

use WebXID\WpPostWrapper\Example\Category
use WebXID\WpPostWrapper\Example\SimpleBlock;


/** @var Category $post */
$category = Category::factory(get_queried_object());

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages