How to modify single widget in child theme?

Looks like I’ve found the answer here. Here’s the working version of the code I’m using in my child theme’s functions.php file. function my_widgets_init() { register_sidebar( array( ‘name’ => esc_html__( ‘Default Sidebar’, ‘codilight-lite’ ), ‘id’ => ‘sidebar-1’, ‘description’ => ”, ‘before_widget’ => ‘<aside id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</aside>’, ‘before_title’ => ‘<h2 class=”widget-title”><span>’, ‘after_title’ => … Read more

Trying to create dynamic widget area using post ID

In your code you are trying to register a different sidebar for every post. Now, that would be possible (though with slightly different code), but it would mean that if you have, say, a hundred posts, you would have hundred widget areas in your admin, all of which you would have to fill with different … Read more

How to display first post thumbnail as a background image of a widget?

Few notes: Just use the_title(); instead of echo get_the_title(); Use the_title_attribute() for title attributes. No need to override the global $wp_query when you use a secondary query. Then use wp_reset_postdata() after your secondary query loop. Use the_permalink() that escapes the permalink, instead of the unescaped echo get_permalink(); There’s the has_post_thumbnail() to check if the post … Read more

How to limit number of number of categories displayed by categories widget

You could show the Category widgets as a dropdown instead, if you have large number of categories. I’m not sure how useful it is to limit categories when ordered by name. You might try to order by count to display the most used categories: add_filter( ‘widget_categories_args’, function( $args ) { $args[‘number’] = 1; $args[‘orderby’] = … Read more