-
Notifications
You must be signed in to change notification settings - Fork 0
Templates and Theming
AlphaListing automatically adapts the directory layout to improve readability on wide screens.
On larger viewports, AlphaListing switches to multiple columns when a letter group contains at least 15 items. A second column appears at 11 items (6 items in the first column and 5 in the second), and a third column is added at 21 items if the layout allows it. The plugin continues balancing items across columns up to a practical limit of 15 columns, ensuring listings remain visually balanced.
Customize AlphaListing by overriding its templates inside your theme.
- Copy
templates/a-z-listing.phpfrom the plugin into your theme's root directory. - Rename the file to
a-z-listing.phpfor the main listing ora-z-listing-section.phpwhen targeting a specific section.
Starting with the example template is recommended because it demonstrates the available helper methods.
AlphaListing's templating API mirrors the standard WordPress loop with a separate loop for letters and items.
Key methods include:
-
$a_z_query->the_letters()— prints the alphabet and links letters that have items. -
$a_z_query->have_letters()— returns whether additional letters remain in the letter loop. -
$a_z_query->the_letter()— advances to the next letter; wrap the item loop inside this loop. -
$a_z_query->have_items()— mirrorshave_posts()for iterating the items within the current letter. -
$a_z_query->the_item()— prepares the current item, similar tothe_post().
Within the item loop you can call familiar WordPress template tags such as the_content(). When displaying taxonomy terms, use AlphaListing's helper methods to ensure titles and permalinks resolve correctly.
-
$a_z_query->the_title()— prints the current item's title. -
$a_z_query->get_the_title()— returns the title without printing it. -
$a_z_query->the_permalink()— prints the current item's permalink. -
$a_z_query->get_the_permalink()— returns the permalink without printing it. -
$a_z_query->the_item_id()— prints the current item's ID. -
$a_z_query->get_the_item_id()— returns the ID without printing it.
These helpers normalize output whether the listing is built from posts (WP_Post) or taxonomy terms (WP_Term).