How to remove Help tab and the Dashboard widget area’s empty border

The code below will remove the Help Tab and will hide the extra two Dashboard widget areas: add_action( ‘admin_head’, ‘wpse209151_dashboard_cleanup’ ); function wpse209151_dashboard_cleanup() { $screen = get_current_screen(); // Bail if we’re not looking at the dashboard if ( ‘dashboard’ !== $screen->base ) { return; } // Deal with the Help Tabs $screen->remove_help_tabs(); // Hide the … Read more

Address automatically generated ids in css [closed]

Use a plugin to add custom css classes. This plugin does just that and a little more: https://wordpress.org/plugins/widget-css-classes/ For example, add the class .recent-posts to the recent posts widgets. Then you should be able to style them just like any other css class.

Simple php in wordpress widget [closed]

add_action( ‘wp_dashboard_setup’, ‘register_my_dashboard_widget’ ); function register_my_dashboard_widget() { wp_add_dashboard_widget( ‘net_profit_widget’, ‘Net Profit Calculator’, ‘net_profit_widget_display’ ); } function net_profit_widget_display() { $subPrice = 0; $subnumb = 0; if (array_key_exists(‘subprice’, $_POST) !== false) { $subPrice = $_POST[‘subprice’]; } if (array_key_exists(‘subnumb’, $_POST) !== false) { $subnumb = $_POST[‘subnumb’]; } $payperc = “2.9”; $paystan = “0.3”; $netprof = “N/A”; $expense = … Read more

Enabled checkbox by default in WordPress widgets

Please note when checkbox is not checked then key is not set in posted form data. So when you uncheck show_post_count, posted array does not has this key and in update() function you are parsing it with default value. $new_instance = wp_parse_args( (array) $new_instance, self::get_defaults() ); Thus $instance[‘show_post_count’] will have 1 always even when you … Read more

display widget checkbox selection on frontend

Without actually knowing what you’re trying to achieve I see the following problems: $post variable is not defined in your widget() method. Try setting it using $post = get_post( get_the_ID() ) for instance. By the time you call foreach ($posts as $post) { … } $posts variable is also not set. You need some query … Read more