Forums

function add_meta_box does not exist (4 posts)

  1. rajuru
    Member
    Posted 3 years ago #

    hello,
    today while going to make a plugin, I found this problem. after trying a lot i see that add_meta_box() function shows it does not exist.

    here is the code I run to test availability:
    if(function_exists('add_meta_box')) {
    echo 'This function is available';
    } else {
    echo 'This function is not available';
    }

    Output:
    This function is not available

    I get same thing on 2.7 and 2.6.2. but I can easily see that the function is available in template.php file. even my editor (eclipse) can jump to the function when I click.

    how can I solve it? i need to add an extra box in post created/edit area.

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    That means add_meta+box hasn't been "defined" yet.

    Ozh explains:
    http://planetozh.com/blog/2008/02/wordpress-snippet-add_meta_box/

    Other:
    Function_Reference/add_meta_box
    Plugin_API

  3. rajuru
    Member
    Posted 3 years ago #

    hello Michael,
    Thanks for your reply. but how to define it? i see the links says this feature is introduced by WordPress 2.5+. so it is a core function. isn't it?

    thanks

  4. MichaelH
    Volunteer
    Posted 3 years ago #

    You don't define it, but as Ozh explains:

    The catch here is to hook the function that add our "meta box" (here: add_some_box()) late enough so that the function it needs, add_meta_box(), has been defined. Hooking on 'admin_menu' is fine.

Topic Closed

This topic has been closed to new replies.

About this Topic