Objective: To create a WordPress dashboard widget that will show in the admin section and will display RSS feeds.
The following code – after “// Start Dashboad RSS widget example” and before “// End Dashboad RSS widget example” – can be copied and pasted inside of your plguin file or themes function file.
Explanations:*Sections of the code preceded by “//” contains explanations of the codes functions.*wpkb – Each instance of “wpkb” is a customization to each function so that it is not confused by WordPress with other theme or plugins that might be calling the same function in a more generic manner. This is considered a best practice in the WordPress eco system. Eg. “wpkb_custom_dashboard_widgets()” is a better option than “custom_dashboard_widgets()”
// Start Dashboad RSS widget exampleadd_action(‘wp_dashboard_setup’, ‘wpkb_custom_dashboard_widgets’);function wpkb_custom_dashboard_widgets() {global $wp_meta_boxes;
//The second should contain the name that you want to display at the top of your widget. In this example we used “WP Knowledge Base News”wp_add_dashboard_widget(‘custom_help_widget’, ‘WP Knowledge Base News’, ‘wpkb_dashboard_news’);}
function wpkb_dashboard_news() {
//This calls and displays the feedwp_widget_rss_output(array(‘url’ => ‘http://wpdocs.co/feed/?utm_source=wordpress_org_descpage&utm_medium=link&utm_campaign=wp_knowledge_base’,‘title’ => ‘wpDocs Blog’,‘items’ => 3,‘show_summary’ => 0,‘show_author’ => 0,‘show_date’ => 1,));
//This is an option section that can be used to display text, urls etc. We decided to use a button to visit the main blog sourceecho _e(‘
‘);}// End Dashboad RSS widget example
Podchaser is the ultimate destination for podcast data, search, and discovery. Learn More