add_a_z_numbers( string $position = 'after', bool $group = false )

Returns a function for use in the a_z_listing_alphabet filter.


Description


Parameters

$position

(string) (Optional) set to before to place the numbers first. Any other value will place them last.

Default value: 'after'

$group

(bool) (Optional) group the numbers in a single collection rather than individually

Default value: false


Source

File: partials/a-z-listing.php

function add_a_z_numbers( $position = 'after', $group = false ) {
	add_filter( 'a-z-listing-alphabet', function( $alphabet ) use ( $position, $group ) {
		$numbers = '0,1,2,3,4,5,6,7,8,9';
		if ( true === $group ) {
			$numbers = '0123456789';
			add_filter( 'the-a-z-letter-title', function( $letter ) {
				if ( '0' === $letter ) {
					return '0-9';
				}
				return $letter;
			});
		}
		if ( 'before' === $position ) {
			return join( ',', array( $numbers, $alphabet ) );
		}
		return join( ',', array( $alphabet, $numbers ) );
	} );
}

Changelog

Changelog
Version Description
1.8.0 Add $group parameter and functionality to group numbers into a single collection.
1.7.0 Introduced.


User Contributed Notes

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