Title: Error creating a Shortcode
Last modified: August 21, 2016

---

# Error creating a Shortcode

 *  Resolved [Bultack](https://wordpress.org/support/users/bultack/)
 * (@bultack)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/error-creating-a-shortcode/)
 * Hi there,
 * I’m trying to create shortcodes and I started with the examples that shows the
   WordPress Codex
 * function foobar_func( $atts ){
    return “foo and bar”; } add_shortcode( ‘foobar’,‘
   foobar_func’ );
 * I put that code in function.php file and when I run WordPress it returns that
   error:
 * Fatal error: Call to undefined function add_shortcode() in XXXX on line YYY
 * EDIT: I solved the problem, the error was that i wrote the function in the wrong
   functions.php. Now I put the function in function.php of my theme and works good.

The topic ‘Error creating a Shortcode’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Bultack](https://wordpress.org/support/users/bultack/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/error-creating-a-shortcode/)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
