In views when you use the table layout and don't select labels it still creates an empty header, for example:

<th class="views-field views-field-field-address-1"></th> 

I can hide it with CSS. What would I have to do to access the render array and unset the element before the HTML is generated?

Is there any other way to remove the <th> tag?

2 Answers 2


Implement hook_preprocess_views_view_table(&$vars) in theme or custom module and set $vars['header'] to empty array. Template completely ignores thead when header variable is empty. For example:

function MY_THEME_preprocess_views_view_table(&$vars) {
  if ($vars['view']->name == "my_view") {
    $vars['header'] = array();

A more general solution to the problem could be implemented in your theme by preprocessing the theme_table.

In other words, in your template.php file of your theme, write a function like this:

function MY_THEME_preprocess_table(&$variables) {
  if (!empty($variables['header'])) {
    foreach($variables['header'] as $cell) {
      if (!empty($cell)) {
    $variables['header'] = array();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.