Title: WP_Themes_List_Table::prepare_items
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Themes_List_Table::prepare_items()

## In this article

 * [Source](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#related)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#wp--skip-link--target)

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#source)󠁿

    ```php
    public function prepare_items() {
    	$themes = wp_get_themes( array( 'allowed' => true ) );

    	if ( ! empty( $_REQUEST['s'] ) ) {
    		$this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) );
    	}

    	if ( ! empty( $_REQUEST['features'] ) ) {
    		$this->features = $_REQUEST['features'];
    	}

    	if ( $this->search_terms || $this->features ) {
    		foreach ( $themes as $key => $theme ) {
    			if ( ! $this->search_theme( $theme ) ) {
    				unset( $themes[ $key ] );
    			}
    		}
    	}

    	unset( $themes[ get_option( 'stylesheet' ) ] );
    	WP_Theme::sort_by_name( $themes );

    	$per_page = 36;
    	$page     = $this->get_pagenum();

    	$start = ( $page - 1 ) * $per_page;

    	$this->items = array_slice( $themes, $start, $per_page, true );

    	$this->set_pagination_args(
    		array(
    			'total_items'     => count( $themes ),
    			'per_page'        => $per_page,
    			'infinite_scroll' => true,
    		)
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-themes-list-table.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/class-wp-themes-list-table.php#L50)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/class-wp-themes-list-table.php#L50-L86)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Themes_List_Table::search_theme()](https://developer.wordpress.org/reference/classes/wp_themes_list_table/search_theme/)`wp-admin/includes/class-wp-themes-list-table.php` |  | 
| [wp_get_themes()](https://developer.wordpress.org/reference/functions/wp_get_themes/)`wp-includes/theme.php` |

Returns an array of [WP_Theme](https://developer.wordpress.org/reference/classes/wp_theme/) objects based on the arguments.

  | 
| [WP_Theme::sort_by_name()](https://developer.wordpress.org/reference/classes/wp_theme/sort_by_name/)`wp-includes/class-wp-theme.php` |

Sorts themes by name.

  | 
| [wp_unslash()](https://developer.wordpress.org/reference/functions/wp_unslash/)`wp-includes/formatting.php` |

Removes slashes from a string or recursively removes slashes from strings within an array.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_themes_list_table/prepare_items/?output_format=md#)

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_themes_list_table%2Fprepare_items%2F)
before being able to contribute a note or feedback.