I am building a theme that allows widgets to be dragged & dropped, essentially turning WP into a desktop-like environment where the admin controls what "apps" are available via the widget panel.

This is going reasonably well, except that it would be nice is if there were a way for the admin to store starting locations for all of the widgets (and presumably, more meta-data later)

In practical terms, this means I want 2 custom fields to appear on each widget in the admin panel, and then for there to be a hook to spit that data out when the widgets are printed on the page (in my case as some inline style values).

I am building this "desktop" using home.php

I am not sure if wordpress is actually built to do this, but it seems vaguely plausible. Any thoughts? Thanks!

  • You are needing/hoping to add fields to any widget on the site, whether made by you or by somebody else?
    – s_ha_dum
    Commented Oct 16, 2013 at 23:28
  • @s_ha_dum that is correct Commented Oct 17, 2013 at 14:19

1 Answer 1


Crude code. I have never tried this but I can get you part of the way there.

Add a field...

  function ($instance) {
    echo '<input type="text" value="c00l" />';
    return null;

And there is a hook that runs on settings update.

  function($instance, $new_instance, $old_instance, $this) {
    var_dump($instance, $new_instance, $old_instance, $this); die;

However, it looks like you need to add an option/setting to the widget before that hook will work and I don't see how to do that. I am probably missing something obvious but don't have time to do more research right now.



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.