Using WordPress ‘display_plugins_table()’ PHP function

The display_plugins_table() WordPress PHP function is used to display plugin content based on a provided plugin list.

Usage

To use the display_plugins_table() function, simply call it in your code. It does not require any parameters.

Example:

display_plugins_table();

Parameters

  • This function does not require any parameters.

More information

See WordPress Developer Resources: display_plugins_table()

Examples

Displaying Plugin Table on a Custom Page

In this example, the function is used to display the plugin table on a custom page.

// Create a shortcode for displaying the plugins table
add_shortcode('my_plugins_table', 'display_plugins_table_shortcode');
function display_plugins_table_shortcode() {
    ob_start();
    display_plugins_table();
    return ob_get_clean();
}

Displaying Plugin Table in a Dashboard Widget

In this example, the function is used to display the plugin table within a custom dashboard widget.

// Create a dashboard widget
add_action('wp_dashboard_setup', 'my_dashboard_widgets');

function my_dashboard_widgets() {
    wp_add_dashboard_widget('my_plugins_table_widget', 'My Plugins', 'my_plugins_table_function');
}

function my_plugins_table_function() {
    display_plugins_table();
}

In this example, the function is used to display the plugin table in the footer of your site.

add_action('wp_footer', 'display_plugins_in_footer');

function display_plugins_in_footer() {
    echo '<div id="plugins-list">';
    display_plugins_table();
    echo '</div>';
}

Displaying Plugin Table on Admin Page

In this example, the function is used to display the plugin table on a custom admin page.

add_action('admin_menu', 'my_admin_menu');

function my_admin_menu() {
    add_menu_page('My Plugins Page', 'My Plugins', 'manage_options', 'my-plugins-page', 'my_plugins_page');
}

function my_plugins_page() {
    display_plugins_table();
}

Displaying Plugin Table in a Post Using Shortcode

In this example, we’re creating a shortcode that you can use in a post to display the plugin table.

// Create a shortcode for displaying the plugins table
add_shortcode('display_plugins_table', 'display_plugins_shortcode');

function display_plugins_shortcode() {
    ob_start();
    display_plugins_table();
    return ob_get_clean();
}

Just add [display_plugins_table] to any post where you want to display the plugin table.