Documentation

PostRepository
in package

Repository for wp_posts queries using the WP_Query-based QueryBuilder.

Use this for custom post type (CPT) persistence on wp_posts.

Table of Contents

Properties

$postType  : string

Methods

__construct()  : mixed
count()  : int
find()  : WP_Post|null
first()  : WP_Post|null
get()  : array<string|int, WP_Post>
paginate()  : WP_Post[], total: int, per_page: int, current_page: int, pages: int}
newQuery()  : QueryBuilder
Get a fresh QueryBuilder instance scoped to this post type.

Properties

Methods

__construct()

public __construct(string $postType) : mixed
Parameters
$postType : string

find()

public find(int $id) : WP_Post|null
Parameters
$id : int
Return values
WP_Post|null

first()

public first() : WP_Post|null
Return values
WP_Post|null

get()

public get() : array<string|int, WP_Post>
Return values
array<string|int, WP_Post>

paginate()

public paginate([int $page = 1 ][, int $perPage = 20 ]) : WP_Post[], total: int, per_page: int, current_page: int, pages: int}
Parameters
$page : int = 1
$perPage : int = 20
Return values
WP_Post[], total: int, per_page: int, current_page: int, pages: int}
On this page

Search results