How to filter widget(s) based on a specific category landing page

First idea: You can create custom widget which will inside it’s displaying logic contain your necessary conditionals check to display only necessary or variable content, utilizing is_category() conditional. Check oficiall widget’s docs and tutorial https://developer.wordpress.org/themes/functionality/widgets/ Another idea: You can use filter sidebars_widgets inside which you’ll remove unnecessary widgets out of being rendered based on your … Read more

How to get dropdown instance value in WordPress custom Widget

The cat_drop setting is empty because your drop-down menu, or the select field doesn’t have the proper name value, so PHP isn’t receiving the selected option/value. So to fix the issue, just add the proper name value to the select field: <!– Wrapped for brevity. –> <select name=”<?php echo $this->get_field_name( ‘cat_drop’ ); ?>” id=”<?php echo … Read more

Loading the native WordPress image uploader in custom widget

All you have to do is to load a couple of scripts, four, to be precise. Register your widget class first Load the media library Pass some variables to translate things properly (please see translation standards of WordPress for more info about this.) Add your own script on top to trigger the modal window and … Read more

WordPress widget not appearing in editors widget list

The “widgets” in the editor are a type of Block, not “true” Widgets, like the ones listed in Appearance > Widgets. Each of these types of widget are developed completely differently, so there isn’t a way to add true widgets as blocks or vice versa, and any added to one section will not automatically appear … Read more

Creating a widget and missing jQuery

Special thanks are offered to @Pat J. The problem was actually with the jQuery code I had written. jQuery(document).ready(function() { // Some Code Goes Here… }) Just take a look at the complete segment: public function doSomethingSpecific() { ?> <script type=”text/javascript” > jQuery(document).ready(function() { console.log(‘Hello World!’); }) } </script> <?php } Since the above function … Read more

PHP Warning: Declaration of aec_contributor_list::form() should be compatible with WP_Widget::form($instance)

WP_Widget::form() expects to receive an array as a parameter, but the plugin’s form() function doesn’t have it. You can probably fix it like this: /** @see WP_Widget::form */ function form ( $instance ) { _e(‘No options available.’, AEC_NAME); } Be aware, though, that if the plugin’s not supported by its developers anymore, there won’t be … Read more