How to count number of published nodes of a specific content type in twig template? I'm looking for a way to achieve this in my Twig file; if the number of published entities of a content type 'promotions' is at least one, a certain entity should be displayed in a content type Shop. I'm trying to show a banner only if there is at least one published promotion entity.
I could use some help with the if-function. I've written it down with I'm trying to do.
if(published promotion entities &gt; 0){
{{ drupal_entity('node', 2668) }}
}

Any ideas to get me going? Thanks!
In a preprocess hook function for your template, you can code something like this.
function MYTHEME_preprocess_TEMPLATE_HOOK(&amp;$variables) {
    $query = \Drupal::entityTypeManager()-&gt;getStorage('node')-&gt;getQuery();
    $query-&gt;condition('type', 'promotions');
    $query-&gt;condition('status', 1);
    $query-&gt;range(0, 1); // only need one
    $results = $query-&gt;execute();
    $variables['has_published_promotions'] = (bool)count($results);
}

has_published_promotions will be available in your Twig template and will be TRUE only when there are published nodes of that type.