I wanted to use a custom twig file for the field_jury in my view. Below functions were necessary in the mymodule.module file:

function MYMODULE_theme() {
  return [
    'views_view_field__field_jury' => [
      'template' => 'views-view-field--field-jury',
      'base hook' => 'views_view_field',
    ]
  ];
}

and

/**
 * Implements hook_theme_suggestions_HOOK().
 *
 * Add views field template suggestions.
 *
 * @inheritdoc
 */
function MYMODULE_theme_suggestions_views_view_field(array $variables) {
  return [
    'views_view_field__' . $variables['field']->field
  ];
}

 


Saved you some valuable time?

Donate and get more free time-saving code on this website in the future.