Why do none of my widgets have a title?

WordPress 5.8 added the ability to add Blocks to sidebars. Blocks do not use the title and markup defined for a sidebar. They just use the normal HTML they would use in the editor. “Legacy” widgets can still be added, and should still have the option to enter a title and use the markup defined … Read more

Need help adding additional controls to a custom widget

Here’s a complete example of the projects widget based on your code. This widget will allow users to specify the number of project posts to display and will also allow a word limit to be enforced for the content. Note that I went with using a word limit for the content instead of a character … Read more

Changing widget options via the functions.php when there are no hooks

After some digging, I’ve arrived at a solution (explained in the comments) – function change_widget_configuration() { $options = get_option(‘widget_some-widget’); // retrieve the options for all occurrences of the named widget* $widget_number = 3; // the id number of the specific occurrence of the widget whose options you wish to alter (this can be obtained simply … Read more

Placing widget to menu

you can register a new sidebar, add it to the menu area and then add a widget to it: you can register a sidebar by adding this function to your functions.php: register_sidebar( array( ‘name’ => __( ‘Site Stat Widget’), ‘id’ => ‘stat-widget’, ‘description’ => __( ‘The Site Stat Widget’), ‘before_widget’ => ‘<li id=”%1$s” class=”widget-container %2$s”>’, … Read more

How do I embed in a text widget?

Shortcodes are not supported in the Text Widget by default. Add the following to your functions.php: // Enable shortcodes in WP Text Widget add_filter( ‘widget_text’, ‘shortcode_unautop’); add_filter( ‘widget_text’, ‘do_shortcode’, 11); Instead of wrapping the video URL in the shortcode, use the following in the Text Widget: For more info on the shortcode, see the Codex.

How to allow PHP In WordPress text widget

Instead you should consider using a shortcode. This is exactly the problem that shortcodes try to solve. By default, Widgets don’t process shortcodes, but that can be easily changed. add_filter( ‘widget_text’, ‘do_shortcode’ ); This would allow you to use any shortcodes in the Widget text area. Next would be to get the PHP code you … Read more

Create variable from widget instance

Where are the widgets settings stored? The widget settings are stored in the wp_options table. You can retrieve it with print_r( get_option( ‘widget_x’ ) ); where x is the $id_base input parameter of the WP_Widget class constructor. If $id_base is empty, then it uses the widget class name in lower case letters, without the prefixes: … Read more