Forcing the title of a text widget on to a new line in the admin area

You can try this custom CSS code to enable multiple title lines for the widgets in the backend: function custom_css_wpse_98587() { echo “<style> .widget-top{height:auto !important;} .widget-title h4, .widget-title span.in-widget-title{ white-space:normal; } </style>”; } add_action(‘admin_head-widgets.php’,’custom_css_wpse_98587′); This is how the widgets show up in my Chrome browser: Before: After:

How do i display the built-in gallery inside a widget?

Widgets don’t usually allow shortcodes in them (they treat them as normal text). What you have to do, is to tell this widget, it should run do_shortcode on it’s text. To do it, you can use this snippet: add_filter(‘widget_text’, ‘do_shortcode’); Just place it in your function.php file. Then you can place shortcodes in Text Widget … Read more

Color Picker Showing Twice When Widget Added to Sidebar

I added code from this example and it works! (wp 9 still has same issue with color picker) <script> ( function( $ ){ function initColorPicker( widget ) { widget.find( ‘.color-picker’ ).wpColorPicker( { change: _.throttle( function() { // For Customizer $(this).trigger( ‘change’ ); }, 3000 ) }); } function onFormUpdate( event, widget ) { initColorPicker( widget … Read more

Best way to add internal link in widget

The page ID can vary in different installation, and it can’t be changed, so an option is to use get_page_by_path because the page slug can be easily changed: <div class=”my-link-box”> <?php $page = get_page_by_path(‘my-page’); ?> <a href=”https://wordpress.stackexchange.com/questions/126876/<?php echo get_permalink($page); ?>”><?php echo $page->post_title; ?></a> </div> However this is not a great solution as well. Once you … Read more

How to check if a widget has no title

Nope, there is no way (thank I can think of) to do this cleanly. Handling of output and related parameters is up to the each wdiget’s individual widget() method. There is no generic way to manipulate it. You could maybe get away with filtering widget save or display instances to force it to always have … Read more

Check which registered sidebar a widget is added to

There isn’t a standard way to do it AFAIK in the form() method; here’s a function to do it: function wp158055_get_sidebar_id( $widget ) { foreach ( wp_get_sidebars_widgets() as $sidebar_id => $widget_ids ) { if ( array_search( $widget->id, $widget_ids ) !== false ) return $sidebar_id; } return false; } And call with $this. Note from the … Read more