Skip to content

Instantly share code, notes, and snippets.

@dipakcg
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dipakcg/cf11c3cdac1092e8e866 to your computer and use it in GitHub Desktop.
Save dipakcg/cf11c3cdac1092e8e866 to your computer and use it in GitHub Desktop.
WordPress - Add custom RSS feeds to dashboard
/* ========================================== */
// Add this code to theme's functions.php
// It removes the default WordPress feeds and adds your custom feeds to the admin dashboard.
/* ========================================== */
function dcg_dashboard_widgets() {
global $wp_meta_boxes;
// remove unnecessary widgets
// var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs
unset(
$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'],
$wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'],
$wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
);
// add a custom dashboard widget
wp_add_dashboard_widget( 'dashboard_custom_feed', 'News from Dipak C. Gajjar', 'dcg_dashboard_custom_feed' ); // add new RSS feed output
}
function dcg_dashboard_custom_feed() {
echo '<div class="rss-widget">';
wp_widget_rss_output(array(
'url' => 'http://dipakgajjar.com/feed/', // Feed URL
'title' => 'News from Dipak C. Gajjar',
'items' => 4,
'show_summary' => 1,
'show_author' => 0,
'show_date' => 1
));
echo "</div>";
}
add_action('wp_dashboard_setup', 'dcg_dashboard_widgets');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment