WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For organisation, I'm trying to split up the functions.php file into separate files. In particular the functions for shortcodes in a separate file, with the shortcodes being defined in functions.php. Here's the code in the functions.php:-

locate_template( array( 'inc/shortcode-functions.php' ), true, true ); 
add_shortcode( 'abc-row', 'echo_abc_row' );
add_shortcode( 'abc-span', 'echo_abc_span' );

I have taken the code out of inc/shortcode-functions.php into the functions.php, so does appear to work, and no error is coming up in debug mode, so I'm a bit stumped. Any ideas?

share|improve this question

The locate_template() function is intended to be used to locate/include template files, not functional files.

Just use include() and/or require() to include functional files in functions.php.

share|improve this answer

If and only if you are looking for a way to make your shortcode-functions.php file overrideable by child themes I'd suggest get_template_part, like this:


Notice that there is no .php at the end. That will load your file, whereas locate_template will fail. (I just tested it.) The difference between the two is that get_template_part does a little bit more work constructing file paths.

If you aren't trying to make it overrideable by a child theme, just use include.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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