Quantcast
Channel: content – WPInsite
Viewing all articles
Browse latest Browse all 4

Remove WordPress Dashboard News Feed and Add Your Own

$
0
0

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

Remove WordPress Dashboard News Feed and Add Your Own

Remove WordPress Dashboard News Feed and Add Your Own

Understanding what is an RSS News Feed is

RSS (originally RDF Site Summary, often dubbed Really Simple Syndication) is a family of web feed formats used to publish frequently updated works—such as blog entries, news headlines, audio, and video—in a standardized format. An RSS document (which is called a “feed”, “web feed”, or “channel”) includes full or summarized text, plus metadata such as publishing dates and authorship.

RSS feeds benefit publishers by letting them syndicate content automatically. A standardized XML file format allows the information to be published once and viewed by many different programs. They benefit readers who want to subscribe to timely updates from favorite websites or to aggregate feeds from many sites into one place.

RSS feeds can be read using software called an “RSS reader”, “feed reader”, or “aggregator”, which can be web-based, desktop-based, or mobile-device-based. The user subscribes to a feed by entering into the reader the feed’s URI or by clicking a feed icon in a web browser that initiates the subscription process. The RSS reader checks the user’s subscribed feeds regularly for new work, downloads any updates that it finds, and provides a user interface to monitor and read the feeds. RSS allows users to avoid manually inspecting all of the websites they are interested in, and instead subscribe to websites such that all new content is pushed onto their browsers when it becomes available.

Removing the default WordPress Dashboard News Feeds and adding your own

This code snippet demonstrates how you can remove certain news feeds from the WordPress dashboard and replace them with your own content.

Navigate to wp-content -> themes -> your-curent-theme and open the functions.php file.

Add the below code to your functions.php file located in your theme directory.

add_action('wp_dashboard_setup', 'my_dashboard_widgets');

function my_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 WPInsite', 'dashboard_custom_feed_output' );
}

function dashboard_custom_feed_output() {
	echo '<div class="rss-widget">';
	wp_widget_rss_output(array(
		'url' => 'http://www.wpinsite.com/feed',
		'title' => 'What\'s happening at WPInsite',
		'items' => 2,
		'show_summary' => 1,
		'show_author' => 0,
		'show_date' => 1
	));
	echo "</div>";
}

The News Feed as displayed in the WordPress Dashboard

The below images demonstrates how your new RSS News feed will be displayed within the main WordPress Dashboard page.

The new RSS News Feed displayed on the WordPress Dashboard

The new RSS News Feed displayed on the WordPress Dashboard

Code Breakdown – Understanding the wp_add_dashboard_widget function call

The function of the wp_add_dashboard function call is to add a new widget to the administration dashboard, using the WordPress Dashboard Widgets API.

<?php wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback ); ?> 

wp_add_dashboard_widget Parameters

$widget_id – (integer) (required) an identifying slug for your widget. This will be used as its css class and its key in the array of widgets.

$widget_name – (string) (required) this is the name your widget will display in its heading.

$callback – (string) (required) The name of a function you create that will display the actual contents of your widget.

$control_callback  – (string) (optional) The name of a function you create that will handle submission of widget options forms, and will also display the form elements.

Be sure to check out our other great WordPress Code Snippets and WordPress Articles.

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images