PostRepository

WP_Query Wordpress wrapper to query objects

Methods

count($criteria)

Count entities by a set of criteria.

find($id)

Find an entity by its primary key / identifier.

findAll($orderBy, $public=true)

Find all public entities in the repository.

findBy($criteria, $orderBy, $limit, $offset)

Find a single entity related to the main query

findByGuid($ids)

Find entities by guid

findByState($state)

Find a single entity by its state

findOneBy($criteria, $orderBy)

Find a single entity matching a set of criteria.

findOneByGuid($id)

Find one entity by guid

findPostTypes($args=[], $output='names', $operator='and')

Gets a list of all registered post type objects.

findQueried()

Find entities matching a set of criteria.

Example

public function pageAction(Post $post, PostRepository $postRepository)
{
  $context = [
    'post'=>$post,
    'guides'=>$postRepository->findBy(['post_type'=>'guide'],['title'=>'ASC'], 3)
  ];
  
  return $this->render('single.html.twig', $context);
}

Last updated