Hello and thank you for helping in advance,

I am trying to create a widget that lives inside the post.php page for when editing a post that exists (Not new-post.php, I need an ID). This custom widget is going to get the posts ID and shoot it to another database to store it, it'll do this through ajax and have it's own independent save button.

Pretty simple right? Except I can't figure out how to get my widget to show on the post.php page.

Here is my test code in themes/myTheme/functions.php, just to try and get it in the right place...but it's not working.

function artist_associator_dashboard_widget_function(){
    echo "Hello world";

function artist_associator_add_dashboard_widget(){
    wp_add_dashboard_widget('artist_associator_dashboard_widget', 'Artist Associator', 'artist_associator_dashboard_widget_function');

I also tried putting in a few other actions that looked promising but it wasn't working out, couldn't find my functions.

1 Answer 1


For one, Dashboard widgets (what you're using in the example) are for the main wordpress admin page.

I think what you want is this tutorial. You also want to look at add_meta_box to look at how to add a metabox to your post screen. Here's some code from my current project that should help you to add a metabox to the post edit screen.

$m_visitor_info = array(
        'id' => 'argus_edit_visitor',
        'name' => 'Visitor Information',
        'cb' => array( &$this, '_argus_edit_visitor' ),
        'type' => 'visitor',
        'context' => 'normal',
        'priority' => 'high',

add_meta_box( $m_visitor_info['id'], $m_visitor_info['name'], $m_visitor_info['cb'], $m_visitor_info['type'], $m_visitor_info['context'], $m_visitor_info['priority'] );

Change all to suit your preferences. Basically this creates me a custom metabox that appears as the primary input selection for the post (I don't use editor or title support). Context can either be "normal," "advanced," or "side." I haven't found a use for 'advanced' though it's default for some reason..

Anyway, You'll probably need to throw in a check to see whether you're editing an existing page or you're creating a new post.

Though, a better solution perhaps would be to use add_action to hook the save_post event and use your ajax there to save the post ID to your external database.

  • Thank you! I will check this out right now and get back to you with any questions or how it goes!
    – user2645
    Jan 21, 2011 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.