TermRepository

WP_Term_Query Wordpress wrapper to query objects

Methods

count($criteria)

Counts entities by a set of criteria.

find($id)

Finds an entity by its primary key / identifier.

findAll($orderBy, $public=true)

Finds all public entities in the repository.

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

Finds entities by a set of criteria.

findOneBy($criteria, $orderBy)

Finds a single entity by a set of criteria.

findQueried()

Finds a single entity related to the main query

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

Retrieves a list of registered taxonomy names or objects.

Example

public function pageAction(Post $post, TermRepository $termRepository)
{
  $context = [
    'post'=>$post,
    'tags'=>$termRepository->findBy(['taxonomy'=>'tag'],['title'=>'ASC'], 3)
  ];
  
  return $this->render('single.html.twig', $context);
}

Last updated