views_embed_view will be deprecated in Drupal 11.4.0 - How to update your old code

By Shivan Jaikaran, 3 April, 2026

views_embed_view will be deprecated Drupal 11.4.0 and removed from Drupal 13.0.

Here is an easy way to fix this. Currently, you may have something like this:

$variables['content_by_author'] = views_embed_view('VIEW_NAME', 'VIEW_DISPLAY_NAME');

You can replace that with:

$variables['content_by_author] = [
  '#type' => 'view',
  '#name' => 'VIEW_NAME',
  '#display_id' => 'VIEW_DISPLAY_NAME',
];

And if your View requires arguments:

$author_target_id = (int) $variables['node']->get('field_author')->target_id;

$variables['content_by_author'] = [
  '#type' => 'view',
  '#name' => 'VIEW_NAME',
  '#display_id' => 'VIEW_DISPLAY_NAME',
  '#arguments' => [$author_target_id],
];