Using WordPress ‘after-{$taxonomy}-table’ PHP action

The after-{$taxonomy}-table WordPress action fires after the taxonomy list table is displayed. The dynamic part of the action name, $taxonomy, refers to the taxonomy slug.

Usage

add_action('after-{$taxonomy}-table', 'your_custom_function_name');

function your_custom_function_name($taxonomy) {
    // your custom code here
}

Parameters

  • $taxonomy (string) – The taxonomy name.

More information

See WordPress Developer Resources: after-{$taxonomy}-table

Examples

Display a message after the category table

Displays a custom message after the category list table.

add_action('after-category-table', 'display_custom_message');

function display_custom_message($taxonomy) {
    echo 'This is a custom message.';
}

Add a custom button after the post tag table

Adds a custom button after the post tag list table.

add_action('after-post_tag-table', 'add_custom_button');

function add_custom_button($taxonomy) {
    echo '<button class="button">Custom Button</button>';
}

Include custom content after a custom taxonomy table

Include custom content after a custom taxonomy called “book_genre” list table.

add_action('after-book_genre-table', 'include_custom_content');

function include_custom_content($taxonomy) {
    echo 'Custom content for book genres.';
}

Add a custom notice after the taxonomy table

Add a custom notice after the taxonomy list table for a custom taxonomy called “event_type”.

add_action('after-event_type-table', 'display_custom_notice');

function display_custom_notice($taxonomy) {
    echo '<div class="notice notice-info">This is a custom notice.</div>';
}

Display a custom admin message after the category table

Display a custom admin message only for users with the “manage_categories” capability after the category list table.

add_action('after-category-table', 'display_admin_message');

function display_admin_message($taxonomy) {
    if (current_user_can('manage_categories')) {
        echo 'This message is visible only to admins.';
    }
}

Tagged in

Leave a Comment

Your email address will not be published. Required fields are marked *