A_Z_Listing::get_indexed_items()

Sort the posts into an Array based on their index letters


Description


Return

(Array) The posts array keyed by index letter


Source

File: partials/class-a-z-listing.php

	protected function get_indexed_items() {
		$letters = array();

		foreach ( $this->items as $item ) {
			$indices = $this->get_the_item_indices( $item );

			foreach ( $indices as $index => $index_entries ) {
				if ( count( $index_entries ) > 0 ) {
					if ( in_array( $index, array_keys( self::$alphabet ), true ) ) {
						$index = self::$alphabet[ $index ];
					} else {
						$index = '_';
					}

					if ( ! isset( $letters[ $index ] ) || ! is_array( $letters[ $index ] ) ) {
						$letters[ $index ] = array();
					}

					$letters[ $index ] = array_merge_recursive( $letters[ $index ], $index_entries );
				}
			}
		}

		return $letters;
	}

Changelog

Changelog
Version Description
0.8.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.

This site uses Akismet to reduce spam. Learn how your comment data is processed.