Widgets missing after update

I had to restore sidear_widgets in wp_options and any other entries with option_name including ‘widget’ from a database backup to resolve. Something must have go wrong during the update and all widget settings were lost.

Adding widgets with Featured Image via the Customizer run hundreds of queries

The issue boils down to this bit of code in WP_Widget::display_callback(): $was_cache_addition_suspended = wp_suspend_cache_addition(); if ( $this->is_preview() && ! $was_cache_addition_suspended ) { wp_suspend_cache_addition( true ); } This gets called right before WP_Widget_Recent_Posts::widget() and its purpose is to try as best as possible for back-compat to prevent widgets previewed in the Customizer from polluting the object … Read more

Recent Posts – Show all posts

Under settings you can control how many posts there are, you can’t set -1 which would be unlimited posts, but you can set a very high number: But What About just The Homepage? A lot of people get around this by putting a custom query in their homepage template, but those people are doubling the … Read more

Add field to dashboard to update embedded URL on homepage?

Add the below code in the functions.php file and it will create a text field in the general setting options page add_action(‘admin_init’, ’embed_url_initialize’); function embed_url_initialize() { // First, we register a section. This is necessary since all future options must belong to one. add_settings_section( ‘general_settings_section’, // ID used to identify this section and with which … Read more

Multilple single-use widgets with the same output callback

It appears that wp_register_sidebar_widget is a very outdated function from early implementations of widgets. Apparently back then widgets could only be used once each and the output callback name seems to be what made a widget unique, despite the existence of an ID. The single-use nature of these widgets doesn’t appear to be an intentional … Read more

How to save widget fields generated from an array?

OK, so I’ve done some debugging and I know where your problem lies… First of all in update function: public function update( $new_instance, $old_instance ) { $instance = $old_instance; if ( empty( $this->fields ) ) { return $instance; } $instance = $this->save_fields( $new_instance, $old_instance ); return $instance; } You shouldn’t use $old_instance as starting point. … Read more

How to allow your custom widget as block in gutemberg editor

I found the solution here and here. My OOP Code : Block_Type abstract Class Block_Type { public $handle; public $handle_editor; public $handle_block; private $editor_js_file; public $editor_js_file_path; private $editor_css_file; public $editor_css_file_path; private $css_file; public $css_file_path; public function __construct( $handle, $editor_js_file_path = null, $editor_css_file_path = null, $css_file_path = null ) { $this->handle = “h4a-” . $handle; $this->handle_editor … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)