Using WordPress ‘manage_posts_extra_tablenav’ PHP action

The manage_posts_extra_tablenav WordPress action is triggered right after the closing “actions” div in the tablenav for the posts list table. It allows you to add custom content or functionality to the posts list table.

Usage

add_action('manage_posts_extra_tablenav', 'your_custom_function', 10, 1);

function your_custom_function($which) {
    // your custom code here
}

Parameters

  • $which (string): The location of the extra table nav markup, either ‘top’ or ‘bottom’.

More information

See WordPress Developer Resources: manage_posts_extra_tablenav

Examples

Add a custom button to the top of the posts list table

This example adds a custom button to the top of the posts list table.

add_action('manage_posts_extra_tablenav', 'add_custom_button', 10, 1);

function add_custom_button($which) {
    if ($which == 'top') {
        echo '<input type="button" value="Custom Button" class="button" />';
    }
}

Display additional filters at the bottom of the posts list table

This example adds extra filtering options to the bottom of the posts list table.

add_action('manage_posts_extra_tablenav', 'add_extra_filters', 10, 1);

function add_extra_filters($which) {
    if ($which == 'bottom') {
        echo '<select name="custom_filter">';
        echo '<option value="">Select Custom Filter</option>';
        // Add your custom filter options here
        echo '</select>';
    }
}

Add a custom message to the top and bottom of the posts list table

This example adds a custom message to both the top and bottom of the posts list table.

add_action('manage_posts_extra_tablenav', 'add_custom_message', 10, 1);

function add_custom_message($which) {
    if ($which == 'top' || $which == 'bottom') {
        echo '<p>**Custom Message**</p>';
    }
}

Add a search box to the bottom of the posts list table

This example adds a custom search box to the bottom of the posts list table.

add_action('manage_posts_extra_tablenav', 'add_custom_search_box', 10, 1);

function add_custom_search_box($which) {
    if ($which == 'bottom') {
        echo '<input type="search" name="custom_search" placeholder="Custom Search" />';
    }
}

Add custom pagination to the top of the posts list table

This example adds custom pagination controls to the top of the posts list table.

add_action('manage_posts_extra_tablenav', 'add_custom_pagination', 10, 1);

function add_custom_pagination($which) {
    if ($which == 'top') {
        echo '<div class="custom-pagination">';
        // Add your custom pagination controls here
        echo '</div>';
    }
}