I've just applied a theme and got an error such that I cannot even change the theme back to a working one (like Bartik).

I've read other threads but I could use hook_custom theme but I don't know how to get it to work.

What I'm doing is to edit the system.api.php and change the original lines of hook_custom_theme to this:

function hook_custom_theme() {
  // Allow the user to request a particular theme via a query parameter.
  if (1)) { 
    return 'bartik';

I've tried several variations but I don't know what I'm missing. Can anyone help me with this please?

Edit: I've realised that I need to write my own module to run that line of code, is it true? Is there a simpler way to just change the default theme or the weight of the themes programmatically somewhere?

1 Answer 1


You can install drush on your system and then from drush command you can change the theme using

drush vset theme_default <theme_name>

You can do the changes from database also. Either on the commandline, or via an administration interface (eg PHPMyAdmin) enter the following query

UPDATE system SET status=1 WHERE name = '<theme_name>';

Then either:

UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';
TRUNCATE cache_bootstrap;
TRUNCATE cache_block;

Source: https://drupal.org/node/200774

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.