Using WordPress ‘install_themes_table_api_args_{$tab}’ PHP filter

The install_themes_table_api_args_{$tab} WordPress PHP filter allows you to modify the API request arguments for each Install Themes screen tab in the WordPress admin area.

Usage

add_filter('install_themes_table_api_args_{$tab}', 'my_custom_function');
function my_custom_function($args) {
    // your custom code here
    return $args;
}

Parameters

  • $args (array|false): Theme install API arguments.

More information

See WordPress Developer Resources: install_themes_table_api_args_{$tab}

Examples

Modify the search results on the Install Themes screen

This example changes the number of themes shown in the search results tab.

add_filter('install_themes_table_api_args_search', 'change_search_results_count');
function change_search_results_count($args) {
    $args['per_page'] = 15; // Set the number of themes per page to 15
    return $args;
}

This example filters the featured themes to only show themes with a specific tag.

add_filter('install_themes_table_api_args_featured', 'filter_featured_themes');
function filter_featured_themes($args) {
    $args['tag'] = 'minimal'; // Show only themes with the 'minimal' tag
    return $args;
}

Change the sort order for the updated themes tab

This example changes the sort order for the updated themes tab to show themes sorted by rating.

add_filter('install_themes_table_api_args_updated', 'change_updated_themes_order');
function change_updated_themes_order($args) {
    $args['orderby'] = 'rating'; // Sort themes by rating
    return $args;
}

Limit the number of themes in the new themes tab

This example limits the number of themes shown in the new themes tab to 5.

add_filter('install_themes_table_api_args_new', 'limit_new_themes_count');
function limit_new_themes_count($args) {
    $args['per_page'] = 5; // Show only 5 themes per page
    return $args;
}

Add a custom tab to the Install Themes screen

This example adds a custom tab with themes that have a specific tag.

add_filter('install_themes_tabs', 'add_custom_theme_tab');
add_filter('install_themes_table_api_args_custom', 'show_custom_theme_tab');

function add_custom_theme_tab($tabs) {
    $tabs['custom'] = __('Custom', 'textdomain'); // Add custom tab
    return $tabs;
}

function show_custom_theme_tab($args) {
    $args['tag'] = 'custom-tag'; // Show themes with the 'custom-tag' tag
    return $args;
}