WordPress.org

Support

Support » How-To and Troubleshooting » How to get Widget ID in Widget Instance

How to get Widget ID in Widget Instance

  • This is in response to: http://wordpress.org/support/topic/how-ca-i-get-widget-id?replies=14 which is closed.

    $widget_class = explode( $args['widget_id'] );

    $widget_id = $widget_class[ count($widget_class) - 1];

    $widget_array = get_option('widget_nameofyourwidget');

    $widget_array[$widget_id] = $instance;

    update_option('widget_nameofyourwidget', $widget_array);

    This allows you to update Widget Options for an instance of a Widget, inside the Widget Function in the Widget class.

  • The topic ‘How to get Widget ID in Widget Instance’ is closed to new replies.