I was wondering how to get the number of nodes I have, filtered by the node count and status.
For example: how many published articles I have.
I was thinking about using Entity Query to get the node count.
I was wondering how to get the number of nodes I have, filtered by the node count and status.
For example: how many published articles I have.
I was thinking about using Entity Query to get the node count.
This function will give you the count of the node by its status and content type.
Example: if nodeCountState(1,'article');
the count of number of nodes in the article content type which is published will be displayed.
public function nodeCountState($status, $type) {
$query = \Drupal::entityQuery('node')
->condition('status', $status)
->condition('type', $type);
$result = $query->count()->execute();
return $result;
}
Hope this help some one :)