Last active
August 29, 2015 14:16
-
-
Save dipakcg/cf11c3cdac1092e8e866 to your computer and use it in GitHub Desktop.
WordPress - Add custom RSS feeds to dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ========================================== */ | |
// 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