Title: shortcode in functions.php or shortcodes.php
Last modified: August 19, 2016

---

# shortcode in functions.php or shortcodes.php

 *  [gmdavis](https://wordpress.org/support/users/gmdavis/)
 * (@gmdavis)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-functionsphp-or-shortcodesphp/)
 * I am new to wordpress but experienced in php. I read and re-read the [Shortcodes](http://codex.wordpress.org/Shortcode_API)
   API codex. It doesn’t explain where to add a new shortcode function. I assumed“
   wp-includes/shortcodes.php” but that didn’t seem to do anything. In an article
   in [Smashing Magazine](http://www.smashingmagazine.com/2009/02/02/mastering-wordpress-shortcodes/)
   they say it’s “wp-includes/functions.php” When I add my code there, I get the
   error: Fatal error: Call to undefined function add_shortcode() in /Users/garydavis/
   Sites/wordpress/wp-includes/functions.php on line 3557
 * Where do I add the shortcode function I wrote?
 * If one of the aforementioned files, perhaps a wp config setting (or apache setting)
   could be wrong?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-functionsphp-or-shortcodesphp/#post-1397927)
 * Typically you would be adding a shortcode via a plugin or in your theme’s functions.
   php.
 *  Thread Starter [gmdavis](https://wordpress.org/support/users/gmdavis/)
 * (@gmdavis)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-functionsphp-or-shortcodesphp/#post-1397959)
 * This works as described above for my localhost testing server. I also found when
   I tired this on my hosted website, pasting my function in ‘functions.php’ causes
   the same error but in ‘shortcodes.php’ it actually works.
 * This doesn’t jive with what MichaelH said and besides, I hope to have my testing
   server work the same as my hosting server.
 * If anyone has any insight on getting this working on both servers, please reply.
   In the meantime, I’ll delve into plug-ins.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-functionsphp-or-shortcodesphp/#post-1398063)
 * Note: changing core files will require you to make that change when you install
   a WordPress upgrade.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘shortcode in functions.php or shortcodes.php’ is closed to new replies.

 * 3 replies
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/shortcode-in-functionsphp-or-shortcodesphp/#post-1398063)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
