Dashboard News Feeds


/ Published in: PHP
Save to your folder(s)

If you build WordPress websites for clients, then the number of WordPress news feeds loaded by default in the dashboard might be an annoyance. If you’re clever, you might just inject some of your own client’s news.


Copy this code and paste it in your HTML
  1. add_action('wp_dashboard_setup', 'my_dashboard_widgets');
  2. function my_dashboard_widgets() {
  3. global $wp_meta_boxes;
  4. // remove unnecessary widgets
  5. // var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs
  6. $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'],
  7. $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'],
  8. $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
  9. );
  10. // add a custom dashboard widget
  11. wp_add_dashboard_widget( 'dashboard_custom_feed', 'News from 10up', 'dashboard_custom_feed_output' ); //add new RSS feed output
  12. }
  13. function dashboard_custom_feed_output() {
  14. echo '<div class="rss-widget">';
  15. wp_widget_rss_output(array(
  16. 'url' => 'http://www.get10up.com/feed',
  17. 'title' => 'What\'s up at 10up',
  18. 'items' => 2,
  19. 'show_summary' => 1,
  20. 'show_author' => 0,
  21. 'show_date' => 1,
  22. ));
  23. echo "</div>";
  24. }

URL: http://www.smashingmagazine.com/2011/05/10/new-wordpress-power-tips-for-template-developers-and-consultants/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.