add_action( 'wp_dashboard_setup', 'setup_dashboard_widget'); function setup_dashboard_widget() { add_meta_box( 'my_dashboard_widget', 'Widget using meta box', 'sample_dashboard__widget_view', 'dashboard', 'side', 'high' ); } function sample_dashboard__widget_view() { ?> <div> This is the dashboard widget using meta box - add_meta_box() function </div> <?php }
Output
ref: https://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget
Add the following code to functions.php
//-------------dashboard widget advanced add_action ( 'wp_dashboard_setup', 'my_note_dashboard_widget' ); function my_note_dashboard_widget() { wp_add_dashboard_widget ( 'my_note_dashboard_widget', 'My Note', 'display_my_note_dashboard_widget', 'update_my_note_dashboard_widget' ); } // display function display_my_note_dashboard_widget() { // get saved data $widget_options = get_option ( 'my_note_dashboard_widget_options_note' ); if ($widget_options) { echo '<div class="my-css-class">'. $widget_options . "</div>"; } } // edit function update_my_note_dashboard_widget() { // get saved data $widget_options = get_option ( 'my_note_dashboard_widget_options_note' ); // process update if (isset ( $_POST ) && isset ( $_POST['my_note_dashboard_widget_options_note'] )) { // save update update_option ( 'my_note_dashboard_widget_options_note', $_POST['my_note_dashboard_widget_options_note'] ); } ?> Note <br> <textarea name="my_note_dashboard_widget_options_note" style="width: 100%"><?php echo isset($widget_options) ? $widget_options : ''; ?></textarea> <?php } //-------------end dashboard widget advanced
Output
ref: https://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget
//----- Dashboard widget ----- // function for creating widget view // Function that outputs the contents of the dashboard widget. // The function should echo its output. function simple_dashboard_widget_function() { // Display whatever you want to show echo '<iframe src="http://www.workassis.com" width="100%" height="300" frameBorder="0">Browser not compatible.</iframe>'; } // Create the function use in the action hook function add_dashboard_widgets() { wp_add_dashboard_widget('simple_dashboard_widget', 'Simple Dashboard Widget', 'simple_dashboard_widget_function'); } // Register the new dashboard widget with the 'wp_dashboard_setup' action add_action('wp_dashboard_setup', 'add_dashboard_widgets' ); //-------End of Dashboard widget--------
ref: https://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget