Using WordPress ‘after_theme_row’ PHP action

The after_theme_row action fires after each row in the Multisite themes list table. It is useful for adding custom content or functionality to the themes list in a WordPress Multisite environment.

Usage

add_action('after_theme_row', 'your_custom_function', 10, 3);

function your_custom_function($stylesheet, $theme, $status) {
    // your custom code here
}

Parameters

  • $stylesheet (string) – Directory name of the theme.
  • $theme (WP_Theme) – Current WP_Theme object.
  • $status (string) – Status of the theme.

More information

See WordPress Developer Resources: after_theme_row

Examples

Display a custom message after each theme row

add_action('after_theme_row', 'display_custom_message', 10, 3);

function display_custom_message($stylesheet, $theme, $status) {
    echo '<p>Custom message goes here.</p>';
}

Add a custom CSS class to each theme row

add_action('after_theme_row', 'add_custom_class', 10, 3);

function add_custom_class($stylesheet, $theme, $status) {
    echo '<style>.theme-row-' . $stylesheet . ' { color: red; }</style>';
}

Display the theme version after each theme row

add_action('after_theme_row', 'display_theme_version', 10, 3);

function display_theme_version($stylesheet, $theme, $status) {
    echo '<p>Theme version: ' . $theme->get('Version') . '</p>';
}

Show a custom message if the theme is inactive

add_action('after_theme_row', 'display_message_for_inactive_theme', 10, 3);

function display_message_for_inactive_theme($stylesheet, $theme, $status) {
    if ($status == 'inactive') {
        echo '<p>This theme is currently inactive.</p>';
    }
}
add_action('after_theme_row', 'add_custom_action_link', 10, 3);

function add_custom_action_link($stylesheet, $theme, $status) {
    $custom_link = admin_url('themes.php?custom-action=' . $stylesheet);
    echo '<a href="' . esc_url($custom_link) . '">Custom action</a>';
}