[resolved] How can I set a Widget's title in for use in the Dashboard? (3 posts)

  1. ancawonka
    Posted 5 years ago #


    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?

    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);
  2. ancawonka
    Posted 5 years ago #

    Okay, so it looks like the way to make this happen is to have a "title" field in your widget. I made mine hidden so that people wouldn't be able to set it on their own, but it gets updated when a category is chosen.

  3. Russell Heimlich
    Posted 5 years ago #

    Thanks for this! I was wondering the same thing myself.

Topic Closed

This topic has been closed to new replies.

About this Topic