How to pass same contextual arguments to two view blocks programmatically? I'm trying to pass same arguments to views. Here is my code:

$view = Views::getView('taxonomy_articles');
            if (!empty($age)) {
              $view-&gt;setDisplay('block_6');
              $view-&gt;setArguments([$term-&gt;tid, $age_args]);
              /*
               * override term name with age param
               */
              $termURL = Url::fromRoute('entity.taxonomy_term.canonical', array('taxonomy_term' =&gt; $term-&gt;tid, 'age' =&gt; $age));
              $termName = \Drupal::l(t($term-&gt;name), $termURL);
            }
            else {
              $view-&gt;setDisplay('block_1');
              $view-&gt;setArguments([$term-&gt;tid]);
            }


My else part gets executed and array of term ids goes to block_1, my view block machine name.

What I want is similar like:

              else {
                  $view-&gt;setDisplay(['block_1','block_7']);
                  $view-&gt;setArguments([$term-&gt;tid]);
                }


Is this possible? Can we pass array to $view-&gt;setDisplay ???
While rendering a view you can only use on display.
So it is only possible to loop through your display array and generate the view within that loop like:

          else {
              foreach (['block_1','block_7'] as $display) {
                $view-&gt;setDisplay($display);
                $view-&gt;setArguments([$term-&gt;tid]);
                // You need to render here.
                // The loop will overwrite the first display.
              }
            }