PostMetaRepository
in package
FinalYes
CRUD operations for wp_postmeta.
Use this for custom post type (CPT) metadata.
Table of Contents
Methods
- delete() : void
- deleteBatch() : void
- get() : mixed
- getAllForPost() : array<string|int, mixed>
- primeCache() : void
- Prime meta cache for multiple posts at once (prevents N+1).
- set() : void
- setBatch() : void
Methods
delete()
public
delete(int $postId, string $key) : void
Parameters
- $postId : int
- $key : string
deleteBatch()
public
deleteBatch(int $postId, array<string|int, mixed> $keys) : void
Parameters
- $postId : int
- $keys : array<string|int, mixed>
get()
public
get(int $postId, string $key[, mixed $default = null ]) : mixed
Parameters
- $postId : int
- $key : string
- $default : mixed = null
getAllForPost()
public
getAllForPost(int $postId) : array<string|int, mixed>
Parameters
- $postId : int
Return values
array<string|int, mixed>primeCache()
Prime meta cache for multiple posts at once (prevents N+1).
public
primeCache(array<string|int, int> $postIds) : void
Parameters
- $postIds : array<string|int, int>
set()
public
set(int $postId, string $key, mixed $value) : void
Parameters
- $postId : int
- $key : string
- $value : mixed
setBatch()
public
setBatch(int $postId, array<string|int, mixed> $data) : void
Parameters
- $postId : int
- $data : array<string|int, mixed>