Using WordPress ‘install_themes_dashboard()’ PHP function

The install_themes_dashboard() WordPress PHP function displays tags filter for themes.

Usage

install_themes_dashboard();

Parameters

  • None

More information

See WordPress Developer Resources: install_themes_dashboard()

Examples

Display themes filter on a custom admin page

// Register the custom admin page
add_action('admin_menu', 'custom_admin_menu');
function custom_admin_menu() {
    add_menu_page('Custom Theme Filters', 'Theme Filters', 'manage_options', 'custom_theme_filters', 'display_custom_theme_filters');
}

// Display the themes filter using install_themes_dashboard()
function display_custom_theme_filters() {
    echo '<h2>Custom Theme Filters</h2>';
    install_themes_dashboard();
}

Wrap the themes filter inside a custom shortcode

// Register the shortcode
add_shortcode('custom_themes_filter', 'shortcode_custom_themes_filter');
function shortcode_custom_themes_filter() {
    ob_start();
    install_themes_dashboard();
    return ob_get_clean();
}

Display the themes filter in a custom widget

// Register the widget
add_action('widgets_init', 'register_custom_theme_filter_widget');
function register_custom_theme_filter_widget() {
    register_widget('Custom_Theme_Filter_Widget');
}

// Create the custom widget class
class Custom_Theme_Filter_Widget extends WP_Widget {
    function __construct() {
        parent::__construct('custom_theme_filter_widget', 'Custom Theme Filter');
    }

    function widget($args, $instance) {
        echo $args['before_widget'];
        echo $args['before_title'] . 'Theme Filter' . $args['after_title'];
        install_themes_dashboard();
        echo $args['after_widget'];
    }
}

Add themes filter to a custom post type’s edit page

// Add meta box to custom post type 'my_post_type'
add_action('add_meta_boxes', 'add_custom_theme_filter_meta_box');
function add_custom_theme_filter_meta_box() {
    add_meta_box('custom_theme_filter_meta_box', 'Theme Filter', 'display_custom_theme_filter_meta_box', 'my_post_type', 'side', 'default');
}

// Display the themes filter inside the meta box
function display_custom_theme_filter_meta_box() {
    install_themes_dashboard();
}