WebCraft Tools

  • News
  • WordPress
    • WordPress Basics
    • WordPress Advanced
    • WordPress Performance
    • WordPress Security
    • WordPress Commerce
    • WordPress Troubleshooting
    • WordPress Themes
  • SEO and Analytics
WebCraft Tools › WordPress Advanced › Add Information to the “Right Now” Dashboard Widget

Add Information to the “Right Now” Dashboard Widget

Last updated on April 19, 2017 by Editorial Staff

The “Right Now” WordPress Dashboard widget is a familiar sight on any WordPress install. It displays helpful information as to how many posts, pages, links, categories, and tags you currently have as well as info about the number of comments and widgets. It also tells you the current theme and WordPress version you are running on. All helpful information.

After your site has been around a while you may have added some custom post types, taxonomies or other info you might want to have available as well. This is really easy to do and I’ll show you how by adding  a custom post type to my “Right Now” Dashboard widget.

[php]

add_action( ‘right_now_content_table_end’, ‘your_right_now’ );

function your_right_now() {

// Newsletters
$num_newsletters = wp_count_posts( ‘ninja_newsletters’ );
$num = number_format_i18n( $num_newsletters->publish );
$text = _n( ‘Newsletter’, ‘Newsletters’, intval($num_newsletters->publish) );
if ( current_user_can( ‘administrator’ ) ) {
$num = “<a href=’edit.php?post_type=ninja_newsletters’>$num</a>”;
$text = “<a href=’edit.php?post_type=ninja_newsletters’>$text</a>”;
}
echo “nt”.'<tr class=”first”>’;
echo “nt”.'<td class=”first b b-newsletters”>’ . $num . ‘</td>’;
echo “nt”.'<td class=”t newsletters”>’ . $text . ‘</td>’;
echo “nt”.'</tr>’;

}

[/php]

Here is what you get when you’re done.

Right Now Dashboard Widget

And here is what’s happening in the code.

  • Line 1 : Hooks our function to the right_now_content_table_end action. This hook falls right after the Content section of the “Right Now widget. There are more of these that I’ll share in later.
  • Line 6 – 12 : Gets the count for the custom post type and sets any display elements we will need.
  • Line 13 – 16 : Simply echoes out our new row with the variables we created above.

That’s all there is to it. You could do something similar for custom taxonimies or anything else you might want displayed in the content section of the “Right Now” Dashboard widget. But what if you want you content to be output somewhere else within the widget. You have a few options.

  • right_now_content_table_end
  • right_now_table_end
  • right_now_discussion_table_end
  • rightnow_end
  • activity_box_end

Play around with these different action hooks to get your content placed exactly where you want it…right now. 🙂

Tweet
Pin
Share
0 Shares

Filed Under: WordPress Advanced

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Site Links

  • Contact Us
  • Disclosure Statement
  • Privacy Policy

About WebCraft.tools

WebCraft.tools is your free resource for building, maintaining, and improving your WordPress website. Whether you are building your first site or have been building them for years, WebCraft.tools aims to provide you with tips, tricks, tutorials, and reviews to take your WordPress site to the next level.

© 2017 - 2026 · WebCraft Tools · Built by the WP Ninjas, LLC