I am trying to override / hook theme_table from theme.inc.
My theme name is stat.
I have added following function to my theme template.php.

function stat_table($variables) {
  //table logic here
  return $output;

I have dev env configured with xdebug and while function is 'loaded'/processed when displaying page with table, it is never called.
Original theme_table is called instead. I already tried clearing cache via drupal_theme_rebuild();
Using Drupal 7.

Is there anything I am doing wrong?
How can I debug why is the function not called?

1 Answer 1


use hook_theme_registry_alter.


function MYMODULE_theme_registry_alter(&$theme_registry) {
  $theme_registry['table']['function'] = '_MYMODULE_my_table_theme';

function _MYMODULE_my_table_theme($variables) { ... ... }

  • I do not have my own module, I am using theme. This seems to only work for modules.
    – stkxchng
    Commented May 16, 2017 at 13:27

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.