The WordPress Text widget expands horizontally beyond the margin of the sidebar when added to a sidebar and opened in the admin and I am trying to apply that function to a widget. I see inline css is being dynamically injected when the widget tab is opened and inserts as

div style="z-index: 100; margin-left: -88px;" id="widget-50_text-4" class="widget open"

and though the widget, when opened, is wider than the sidebar, I am not seeing any width property. I figure it is being done with javascript and I have achieved the similar behavior using jQuery .css() but it is not screen size responsive as is the WP text widget, and I had to insert a width value.

Is there an add_filter function to execute this action?

Image Example

  • what theme are you using? – Jen Apr 21 '15 at 22:37
  • It is not theme related. The css is applied to the widget during configuration or editing in the backend, when in open mode. – Kumar Sara Apr 22 '15 at 8:09

This can be set by passing arguments to the $control_options of the parent widget constructor, which is the fourth argument. Here is an example constructor:

class Custom_Widget extends WP_Widget {

     * Sets up the widgets name etc
    function __construct() {

        $widget_options = array(
                'description' => __( 'Featured Pages Widget.', 'affiliate' )

        $control_options = array(
                'width'  => 750

            'custom_widget', // Base ID
            __( 'Custom Widget', 'text_domain' ), // Name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.