Call to undefined function add_action() (5 posts)

  1. emmern
    Posted 6 years ago #

    I'm making a wordpress plugin, but when I try to run add_action(), this error comes up!

    What's wrong?

    [Code moderated as per the Forum Rules. Please use the pastebin]

  2. emmern
    Posted 6 years ago #

    Ok, fine, I'll use the pastebin… (not that this was made clear to me in any way, though)


  3. escapist
    Posted 6 years ago #

    I'm having this problem as well. Trying to use add_action() in functions.php to add a custom post type, but I get this error:

    Fatal error: Call to undefined function add_action() in /home/jasoncarlin/haslayout.com/wp-includes/functions.php on line 4316

    The code I'm using is straight out of the WordPress codex: http://wordpress.pastebin.com/pi1CH0nD

    It seems I just can't use the add_action() function.. Maybe something is corrupted? I am using WordPress v3.0.1. Thanks for any help.

  4. escapist
    Posted 6 years ago #

    I figured out what was causing the problem for me. I was trying to call add_action() from the main functions.php file in my WP root. Stopped giving me trouble when I moved the call to the functions.php file inside my current theme.

  5. mbrinson
    Posted 5 years ago #

    Thanks for posting the follow-up escapist. I was having the same issue.
    Most of the tutorials you read online assume you would know that when they talk about functions.php that it is the one residing in your theme folder.

Topic Closed

This topic has been closed to new replies.

About this Topic