[wp-hackers] How can I control the display title of a widget in the admin area?

anca at anca.tv anca at anca.tv
Thu Apr 22 23:24:55 UTC 2010

Hello there,

I am making a custom Links widget, and I would like to be able to set the
title of the widget (when in the dashboard) to be the name of the Links
Catgory that I'm displaying. The result should be the same as when you're
using a text widget, and you've set a title.

I'm a little bit confused about how to accomplish this.

Does the widget title automatically get set if there is a "title" field?

I think so, because it looks like the appended title is being set in
widgets.dev.js, near line 244:

appendTitle : function(widget) {
 var title = $('input[id*="-title"]', widget);
 if ( title = title.val() ) {
   title = title.replace(/<[^<>]+>/g, '').replace(/</g, '<').replace(/>/g,
	.children('.in-widget-title').html(': ' + title);

My current thinking is to add a hidden field called "title" to the widget,
and set it on Update to the value of the selected category.



More information about the wp-hackers mailing list