Using WordPress ‘dashboard_secondary_link’ PHP filter

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

Usage

add_filter('dashboard_secondary_link', 'your_custom_function');
function your_custom_function($link) {
    // your custom code here

    return $link;
}

Parameters

  • $link (string): The widget’s secondary link URL.

More information

See WordPress Developer Resources: dashboard_secondary_link

Examples

Modify the secondary link URL to redirect to a custom URL.

add_filter('dashboard_secondary_link', 'change_secondary_link_url');
function change_secondary_link_url($link) {
    $link = 'https://example.com/custom-url/';
    return $link;
}

Add a query parameter to the existing secondary link URL.

add_filter('dashboard_secondary_link', 'add_query_parameter');
function add_query_parameter($link) {
    $link = add_query_arg('utm_source', 'dashboard', $link);
    return $link;
}

Change the secondary link URL to point to a local page within your WordPress admin area.

add_filter('dashboard_secondary_link', 'local_page_secondary_link');
function local_page_secondary_link($link) {
    $link = admin_url('edit.php?post_type=page');
    return $link;
}

Remove the secondary link URL completely.

add_filter('dashboard_secondary_link', '__return_empty_string');

Modify the secondary link URL based on the current user’s role.

add_filter('dashboard_secondary_link', 'conditionally_change_secondary_link');
function conditionally_change_secondary_link($link) {
    if (current_user_can('editor')) {
        $link = 'https://example.com/editor-resources/';
    }
    return $link;
}