webxid/wp-post-wrapper

The lib help to wrap WP instances and to cache already collected data

Installs: 6

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/webxid/wp-post-wrapper

v1.0.0 2022-05-16 12:32 UTC

This package is auto-updated.

Last update: 2025-10-16 20:14:30 UTC


README

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