Get the node count by its node type and node status in Drupal 8 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')
            -&gt;condition('status', $status)
            -&gt;condition('type', $type);
    $result = $query-&gt;count()-&gt;execute();
    return $result;
  }


Hope this help some one :)