Declare a $previous_letter variable, and at the end of the foreach give it the value of the current $glossary_letter. Before of show the $glossary_letter make an if condition. If $glossary_letter is different to the $previous_letter then show it.
$previous_letter = null;
foreach ( $postslist as $post ) :
setup_postdata( $post );
$glossary_title = get_post_custom_values($key = 'glossary_title');
$glossary_description = get_post_custom_values($key = 'glossary_description');
$glossary_letter = substr($glossary_title[0], 0, 1);
?>
if ( $glossary_letter !== $previous_letter ):
<h3><?php echo $glossary_letter; ?></h3>
endif;
<p><a href="https://wordpress.stackexchange.com/questions/286889/<?php the_permalink(); ?>"><?php echo $glossary_title[0]; ?></a>: <?php echo $glossary_description[0]; ?></p>
<?php
$previous_letter = $glossary_letter;
endforeach;
Related Posts:
- How to make in WordPress admin panel sortable column for the custom field, that count the number of page impressions?
- How can I sort the order of multiple custom field values in a custom post type?
- Custom post type order by post_title
- Group/list/sort custom post type posts by date in tabs from acf datepicker field
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- How do I set the default admin sort order for a custom post type to a custom column?
- How can I remove the “Add New” button in my custom post type?
- Make custom column sortable
- Using meta_query, how can i filter by a custom field and order by another one?
- How to display categories of my Custom Post Type?
- Inconsistent temporary 404s on whole install | PHP error with post-template.php
- Display a query with multiple post types and same relationship on a single page
- group search results by post type?
- register_post_type sort order by title by default
- Drag n Drop Post Order for multiple Custom Post Types
- Sort custom post type list table by display name of a user id stored as post meta value
- Custom sortable columns ordered by meta-value?
- WordPress Custom Post Types with a page as a parent?
- Query menu_order custom post types
- Get Custom Taxonomy ID within loop
- Custom post status not working
- List page for custom post type?
- How to order adjacent posts (prev / next) by custom field value?
- WordPress post sorting with AJAX
- Ordering posts by custom taxonomy in admin area
- Search that will look in custom field, post title and post content
- Custom Post Type, WP_Query and ‘orderby’
- Filter admin columns by custom post field value
- Sorting a query by custom field date
- Load custom posts with same tag as page
- Custom Taxonomy Template Post List with Sort Order
- Ordering Posts List By Taxonomy Terms?
- Column sorting with emtpy meta values
- Get custom post type by category in a page template
- Number of pages – multiple (custom) post types
- Is it possible to create an “export to PDF” option?
- How do I programmatically add items of content to a custom post type?
- using the_permalink to echo an href into a
- Date archives for custom post type
- If featured image doesn’t exist, show post content
- WP_Query -> sort results by relevance (= most tags / taxonomy terms in common)
- how to sort post in admin column by recently
- How can I add dropdown widget/box to admin post page?
- Custom Post type sort order not working in the admin area
- How to sort a table of custom posts by column containing custom field
- Categories under custom post types doesn’t show properly
- How to get a list of term names of the custom post type im currently on in single.php
- Meta Query “IN” doesn’t work with ACF checkbox filter
- is_singular won’t call my functions?
- Include images from pages in wp search.php results in default wp search
- How do I redirect all 404 errors of a specific post type to another URL?
- Ajax filter with custom taxonomies
- List events by month
- Filter posts with ajax form and checkboxes
- Alphabetical sorting of custom post type – one letter per page
- how to use two permalinks for one custom post type
- Clean URL permalink for custom post type
- sort events based on event date custom field
- How to Sort Custom Field Admin Column by Date
- How to Sort by Date When Using d-m-Y Format
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- Get custom post type REST API not working
- How to save the checked boxes?
- Custom post type loops with different page templates
- WP insert post PHP function dynamically generated Custom Fields
- Limit Authors to their Own Posts on front-end excluding admins
- How to get only one category of custom post type?
- How can I programmatically save data into custom fields that contain serialized data?
- Adding a span when custom post type is updated
- Inserting data into `post meta` table?
- Error after deleting Custom Post Type with a function (no trash used)
- WordPress is executing URL in code when called via wp_mail()
- Get all taxonomies for all post types
- How to redirect all pages of a custom post type [duplicate]
- Row actions not showing? Why?
- Displaying custom post type on front page
- Append taxonomy terms as class names in markup?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- Sort Posts Best Practice
- Custom Post Type sorted by Title
- How do you output custom code between posts in the loop?
- Show ACF field from custom taxonomy and display on the single template
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Change message given when deleting post from custom post type
- Display children and grandchildren of a custom post type
- How to append element after thumbnail
- How to add new tab to admin list of posts and handle result list
- wordpress custom post type remove duplicate menu item
- Using WPAlchemy metabox values in another metabox
- Sort by two dates. Default entry date and custom field if present
- is_page_template not working as expected
- List terms from Custom Taxonomy
- How do I sort a custom post type admin column using two meta keys?
- Custom-post-type-archive: posts sorted/filtered by year?
- WP_Query search posts by custom post type and custom taxonomy
- Dynamic Custom Post Type Plugin
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- I am having a problem with form updating/editing WordPress post on the frontend
- How to filter out post type meta?
- query_posts with a custom post type, a meta_query and sorting by post date?