0

I want to create an input field in the dashboard where I can put in links or text which will update a section I define on the actual website. I know I can just edit the template but I want to make things easier for the client.

To be a bit more specific, I have a 'latest updates' section in the header and the client has requested that he'd like to update this manually. So I'd like to create an input box of some sort in the dashboard so he can easily enter text (or links), click save, and have it reflected on the website (in the header).

Can someone give me a starting point?

2

This is pretty easy to do with the Dashboard Widgets API http://codex.wordpress.org/Dashboard_Widgets_API.

Here are the steps I would take to create this:

  1. Queue up a jQuery script for AJAX handling
  2. Create a PHP AJAX function and corresponding AJAX hook for saving the form data
  3. Create the dashboard widget with HTML form input(s)

Here's a sample for adding a simple dashboard widget:

function foo_dash_widget_content() {
    //Insert your form element with AJAX capability
}

function foo_dash_widget() {
    wp_add_dashboard_widget('foo-dash', __('Foo Dash Widget', 'foodash'), 'foo_dash_widget_content');
} 
add_action('wp_dashboard_setup', 'foo_dash_widget');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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