How do I rebind event after widget save

WordPress provides callbacks for widgets interactions. You’re seems interested in two of them: widget-added, widget-updated Usage example: jQuery(document).on(‘widget-updated’, function(e, widget){ // do your awesome stuff here // “widget” represents jQuery object of the affected widget’s DOM element });

Loop through widgets in sidebar

The registered widgets in your sidebar-1 might be [sidebar-1] => Array ( [0] => categories-2 [1] => archives-4 [2] => recent-comments-4 [3] => calendar-2 [4] => search-2 [5] => archives-2 [6] => text-4 [7] => recent-posts-2 [8] => nav_menu-2 ) If you got for example the calendar-2 widget, then from: print_r( $GLOBALS[‘wp_registered_widgets’][‘calendar-2’] ); you will … Read more

Modify recent post sidebar to show post thumbs with out plugins

HERE IS THE SOLUTION /** * Extend Recent Posts Widget * * Adds different formatting to the default WordPress Recent Posts Widget */ Class My_Recent_Posts_Widget extends WP_Widget_Recent_Posts { function widget($args, $instance) { if ( ! isset( $args[‘widget_id’] ) ) { $args[‘widget_id’] = $this->id; } $title = ( ! empty( $instance[‘title’] ) ) ? $instance[‘title’] : … Read more

How to remove the parentheses from the category widget

Add this code to your functions.php file and it will remove the parentheses and surround the post count with a span with a class to easily style it. function categories_postcount_filter ($variable) { $variable = str_replace(‘(‘, ‘<span class=”post_count”> ‘, $variable); $variable = str_replace(‘)’, ‘ </span>’, $variable); return $variable; } add_filter(‘wp_list_categories’,’categories_postcount_filter’); ++Bonus In the archive widget, if … Read more

Is there a way to add more tags to the tag cloud?

The tag cloud widget uses wp_tag_cloud() to display the tags, which defaults to 45 tags. Source: https://developer.wordpress.org/reference/functions/wp_tag_cloud/ One can use the widget_tag_cloud_args filter to change this number (and any other arguments passed to wp_tag_cloud(). Here’s an example: function wpse_235908_tag_cloud_args( $args ) { $args[‘number’] = 70; // the number of tags you want to display. return … Read more

Register multiple sidebars

You just need to use the alternate syntax for foreach. From the php manual: The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. … Read more

$post>ID displays wrong post ID

If i understand correctly you are trying to display a list of child pages of a page in a widget, if so then first check if you are on a page using the conditional tag is_page() then you can use $wp_query->get_queried_object_id() like t31os has pointed out so your widget display function should look like this: … Read more

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