I can’t get my custom widget area to show on my WordPress site

Your have created three sidebars and that are primary_widget_area, secondary_widget_area, footer_widget_area But in the sidebar, you call a different sidebar name sidebar-3; that’s why your sidebars are not displaying. Try the following code in sidebar.php: // To display primary_widget_area sidebar <?php if ( is_active_sidebar( ‘primary_widget_area’ ) ) : ?> <?php dynamic_sidebar( ‘primary_widget_area’ ); ?> <?php … Read more

Can I individually style items in the backend widget list?

Just as @MarkKaplun mentioned in a comment, it’s possible with CSS. Also with Javascript. CSS Approach Let’s look at the Calendar widget, as an example. The id for the widget, in the available widgets list, is of the form: widget-{integer}_calendar-__i__ and in the sidebar it’s: widget-{integer}_calendar-{integer} If we want to display the calendar dashicon before … Read more

Change recent posts widget title

I had a similar situation. Add the following code to your functions.php and see if it works for you. function my_widget_title($title, $instance, $id_base) { if ( ‘recent-posts’ == $id_base) { return __(‘New Title’); } else { return $title; } } add_filter ( ‘widget_title’ , ‘my_widget_title’, 10, 3); Note: this will change the title of all … Read more

Widget – Store and update data

You probably want to look at using WordPress Transients as they can handle both the data and the timestamp/expiration. You can also check out The Deal with WordPress Transients by CSS Tricks which has some good info as well.

Ajax gives 400 error

Explanation: The issue you are likely facing is that you are trying to add your ajax actions from within the widget itself that may be instantiated on the elementor/widgets/widgets_registered hook. If so, this is hook elementor/widgets/widgets_registered is too late and do_action( “wp_ajax_{$action}” ) and do_action( “wp_ajax_nopriv_{$action}” ) have already fired. Working example: NOTE: very rough … Read more

Converting a WordPress widget to a block

The short answer here is no. Widgets are written in PHP and blocks are written in JavaScript. Beyond that there pretty fundamental differences between the two paradigms in the sense of where they are stored, markup output approaches etc. You could take the approach of a dynamic block where the block is rendered on the … Read more

Need some help understanding widgets

Widgets are contained in sidebars (not 100% correct, but good enough). A sidebar is an area in which placement of widgets can be managed in the admin. Widgets are realy an instance of a widget class and usually you can have several widgets of the same class in the same and different sidebars. You can … Read more