How to Get Admin Settings for a widget when using the_widget() with custom widget

If you are going to display a particular instance of a widget you are going to have to know which instance that is. Hard-coding that instance value is not flexible, certainly, but unless you have some other way to identify the widget I don’t see an option.

If you can work out some other way to identify the widget you could crawl the array. For example, you could crawl that array and check the widget title for a particular string (using the default text widget):

$instance = get_option( 'widget_text' ); 
foreach ($instance as $k => $v) {
  if ('hi there' == $v['title']) {
    the_widget('WP_Widget_Text',$instance[$k]);
  }
}

Leave a Comment