Using WordPress ‘dashboard_secondary_feed’ PHP filter

The dashboard_secondary_feed WordPress PHP filter allows you to modify the secondary feed URL for the ‘WordPress Events and News’ dashboard widget.

Usage

add_filter('dashboard_secondary_feed', 'your_custom_function');
function your_custom_function($url) {
    // Your custom code here
    return $url;
}

Parameters

  • $url (string) – The widget’s secondary feed URL.

More information

See WordPress Developer Resources: dashboard_secondary_feed

Examples

Change secondary feed URL

Change the secondary feed URL to a custom URL for your website’s dashboard widget.

add_filter('dashboard_secondary_feed', 'change_secondary_feed_url');
function change_secondary_feed_url($url) {
    $url = 'https://your-custom-url.com/feed';
    return $url;
}

Add a query parameter to the secondary feed URL

Add a query parameter to the secondary feed URL to filter content in the widget.

add_filter('dashboard_secondary_feed', 'add_query_parameter');
function add_query_parameter($url) {
    $url = add_query_arg('category', 'my-category', $url);
    return $url;
}

Force HTTPS for the secondary feed URL

Ensure the secondary feed URL uses HTTPS.

add_filter('dashboard_secondary_feed', 'force_https');
function force_https($url) {
    $url = set_url_scheme($url, 'https');
    return $url;
}

Redirect secondary feed URL to a subdomain

Redirect the secondary feed URL to a subdomain of your website.

add_filter('dashboard_secondary_feed', 'redirect_to_subdomain');
function redirect_to_subdomain($url) {
    $url = str_replace('https://example.com', 'https://subdomain.example.com', $url);
    return $url;
}

Remove the secondary feed URL

Remove the secondary feed URL to disable the ‘WordPress Events and News’ widget’s secondary feed.

add_filter('dashboard_secondary_feed', '__return_false');