I have some repetitive code that I'd like to share across two separate themes. Is there a best practice for something like this?

I know I can simply create an include file in the sites directory and do it that way I just wasn't sure if there was another way to do it that would be cleaner?

Thanks in advance!!

  • 1
    Create a module?
    – Alex Gill
    May 7, 2013 at 15:12

1 Answer 1


Two options that I can think of:

  1. Make the themes sub-themes of a parent theme and put the function in the parent theme's template.php file. (I like this solution because other assets (css, js, templates) can easily be shared as well. But unless the function has to do with presentation, it probably doesn't semantically belong in a theme at all.)
  2. Create a simple module that contains the function.

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.