• I am new to wordpress but experienced in php. I read and re-read the Shortcodes 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 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)
  • Typically you would be adding a shortcode via a plugin or in your theme’s functions.php.

    Thread Starter gmdavis

    (@gmdavis)

    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.

    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.