How to pass a special CSS class into widget li

function widget_display_callback( $params ) { global $wp_registered_widgets; global $my_widget_num; // Global a counter array $id = $params[0][‘widget_id’]; $sidebar_id = $params[0][‘id’]; /* Set some count for each widgets */ if( !$my_widget_num ) { // If the counter array doesn’t exist, create it $my_widget_num = array(); } if( isset( $my_widget_num[ $sidebar_id ] ) ) { // See … Read more

how to remove the default title of Categories widget

There is a filter you can use to do this. (Kruti has even found it, but instead of using it, he modified core files…) $title = apply_filters(‘widget_title’, empty( $instance[‘title’] ) ? __( ‘Categories’ ) : $instance[‘title’], $instance, $this->id_base); So what you really need to do, is to add this to your functions.php: function my_repair_categories_empty_title($title, $instance, … Read more

How to include a file only on dashboard widgets page?

You can use the following code. Asuming that the css file style.css is inside the css folder of your theme: function wpse_126614_enque( $hook ) { if ( ‘widgets.php’ != $hook ) { return; } $template_url = get_template_directory_uri(); wp_enqueue_style( ‘admin-style-widget’, $template_url . ‘/css/style.css’ ); } add_action( ‘admin_enqueue_scripts’, ‘wpse_126614_enque’ );

How to use wordpress content class?

If I understood you correctly, this is what you are trying to achieve: register_sidebar(array( ‘name’ => ‘Sidebar Name’, ‘id’ => ‘sidebar-id’, ‘before_widget’ => ‘<div class=”sidebar_area”>’, ‘before_title’ => ‘<h4>’, ‘after_title’ => ‘</h4><div class=”sidebar_content”>’, ‘after_widget’ => ‘</div></div>’, )); References: register_sidebar

wp_dropdown_pages in widget form

I have no idea why but changing the update function to the following seemed to do the trick: public function update( $new_instance, $old_instance ) { $instance = $old_instance; if( isset( $new_instance[‘page_id’] ) ) { if( $new_instance == ” ) { $instance[‘page_id’] = ”; } else if ( (int) $new_instance[‘page_id’] > 0 ) { $instance[‘page_id’] = … Read more

Widget that shows categories with posts numbers

There is no coding involved here. WordPress has already a build in widget for this function. If you go to the “Widgets” screen. you’ll see that there are a widget called Categories You can drag and drop that to your sidebar where you need to display the widget. When you’ve done that, the widget will … Read more