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
$postType read-only
private
string
$postType
Methods
__construct()
public
__construct(string $postType) : mixed
Parameters
- $postType : string
count()
public
count() : int
Return values
intfind()
public
find(int $id) : WP_Post|null
Parameters
- $id : int
Return values
WP_Post|nullfirst()
public
first() : WP_Post|null
Return values
WP_Post|nullget()
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}newQuery()
Get a fresh QueryBuilder instance scoped to this post type.
protected
newQuery() : QueryBuilder