Using WordPress ‘activity_box_end’ PHP action

The activity_box_end WordPress PHP filter allows you to add custom content at the end of the ‘At a Glance’ dashboard widget.

Usage

add_action('activity_box_end', 'your_custom_function');
function your_custom_function() {
    // your custom code here
}

Parameters

  • No parameters for this action.

More information

See WordPress Developer Resources: activity_box_end

Examples

Display a custom message

Add a custom message to the end of the ‘At a Glance’ widget.

add_action('activity_box_end', 'custom_message_at_glance');
function custom_message_at_glance() {
    echo '<p><strong>Your custom message here!</strong></p>';
}

Display the total number of users

Display the total number of users on your WordPress site.

add_action('activity_box_end', 'display_total_users');
function display_total_users() {
    $user_count = count_users();
    echo '<p><strong>Total Users: ' . $user_count['total_users'] . '</strong></p>';
}

Display custom post type count

Display the total number of published custom post type ‘products’.

add_action('activity_box_end', 'display_custom_post_type_count');
function display_custom_post_type_count() {
    $post_count = wp_count_posts('products');
    echo '<p><strong>Published Products: ' . $post_count->publish . '</strong></p>';
}

Display total number of comments

Display the total number of comments on your WordPress site.

add_action('activity_box_end', 'display_total_comments');
function display_total_comments() {
    $comments_count = wp_count_comments();
    echo '<p><strong>Total Comments: ' . $comments_count->total_comments . '</strong></p>';
}

Add a link to a custom admin page at the end of the ‘At a Glance’ widget.

add_action('activity_box_end', 'add_custom_admin_link');
function add_custom_admin_link() {
    echo '<p><a href="' . admin_url('admin.php?page=your-custom-page') . '">Go to your custom admin page</a></p>';
}