I have a client whom I want to give as much Dashboard control over the admin area as possible. I know how to create a custom dashboard widget that contains just text/html but I have no idea how to create one that contains just a single text input field.

Adding the form html would be straightforward I can see that but I don't know:

  1. Where to submit the form data too
  2. How to redirect back to the Dashboard after the form is submitted
  3. How to retrieve the value in my non-admin theme templates

1 Answer 1


You need a set of functions to :

  • process datas
  • sanitize options
  • allow datas to be updated
  • output the form

I like to proceed this way. I set also a function to grab datas so I can call them the simpliest way :

add_action('wp_dashboard_setup', 'wpse_106458_add_widget');

function wpse_106458_add_widget() {

  $title = my_function_get_options();
  $title = $title['title'];

  wp_add_dashboard_widget('widget_id', $title, 'callback_output', 'widget_control' );

Hope it helps.

EDIT: I wrap it with this :

if ( is_admin() || ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) {/* code goes here */}

This allows to apply code only where it's necessary.

  • Thanks, I really appreciate your help :) I came across this script which I removed from the Theme page and inserted into a Dashboard Widget via functions.php it helped a lot: themeshaper.com/2010/06/03/sample-theme-options
    – Kev
    Jul 14, 2013 at 14:36

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.