Clean the WordPress Dashboard & Add Your Own Content

This little plugin is meant for WordPress multisite. When network activated, it closes all the default dashboard widgets and adds your own. It populates your widget with the title and excerpt of any posts on your root blog that are in the category ‘support.’ It’s meant to make it easy for you to add tutorial links across the site to a place that most users go frequently.

It’s comment up a bit below but there’s not much too it. I remember struggling with something like this a number of years ago. So there is some evidence that I am getting better over time.

Plugin Name: SOLA custom Dashboard
Plugin URI:
Description: For adding directions to the dashboard
Version:     1.0
Author:      Tom Woodward
Author URI:
License:     GPL2
License URI:
Domain Path: /languages
Text Domain: sola-custom

defined( 'ABSPATH' ) or die( 'No script kiddies please!' );

add_action('wp_dashboard_setup', 'sola_custom_dashboard_widgets');
function sola_custom_dashboard_widgets() {
  global $wp_meta_boxes;
  wp_add_dashboard_widget('custom_sola_widget', '<img style="width:100px; display:block; margin:0 auto;" src="'.plugin_dir_url( __FILE__ ).'/imgs/logo.png"><h1>Guidance</h1>', 'sola_custom_dashboard_posts');

function sola_custom_dashboard_posts() {
    echo '<p>Use the links below to learn more about Sola.</p>';
    //echo network_home_url();
    // WP_Query arguments
    switch_to_blog(1);//switch to the home blog but you could put another source URL here
    $args = array(
      'post_type'              => array( 'post' ),
      'post_status'            => array( 'public' ),
      'order'                  => 'ASC',
      'orderby'                => 'date',
      'category_name'          => 'support',// using the category support slug here

// The Query
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
  while ( $query->have_posts() ) {
    $post = $query->the_post();

    // do something
    echo '<hr/><h2><a href="' . get_the_permalink() .'">'. get_the_title() . '</a></h2>';
    echo '<p>' . get_the_excerpt() . '</p>';

  } else {
    // no posts found

  // Restore original Post Data
  Disable Default Dashboard Widgets
function disable_default_dashboard_widgets() {
  global $wp_meta_boxes;
  // wp..
  // bbpress
  // yoast seo
  // gravity forms
add_action('wp_dashboard_setup', 'disable_default_dashboard_widgets', 999);

//LOGGER -- like frogger but more useful

if ( ! function_exists('write_log')) {
   function write_log ( $log )  {
      if ( is_array( $log ) || is_object( $log ) ) {
         error_log( print_r( $log, true ) );
      } else {
         error_log( $log );


Comments on this post

No comments.

Leave a Reply

Trackbacks and Pingbacks on this post

No trackbacks.

TrackBack URL