Title: Add count
Last modified: August 31, 2016

---

# Add count

 *  Resolved [starflow](https://wordpress.org/support/users/starflow/)
 * (@starflow)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/add-count/)
 * Hi Daniel
 * Is there a way to add a ‘count’ to the list.
 * It would be useful to have a count of each item in the list.
 * Thanks
 * [https://wordpress.org/plugins/a-z-listing/](https://wordpress.org/plugins/a-z-listing/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/add-count/#post-7345857)
 * The widget does not include the required functionality, however the index page
   itself can be customised to include a count anywhere you like. The key is the
   function `num_a_z_items()` which contains the number of the current letter in“
   the letter loop”. You will need to copy the file a-z-listing/templates/a-z-listing.
   php to your theme and modify to contain a line similar to the below wherever 
   you need it to appear in your listing page.
 * `<?php echo num_a_z_items(); ?>`
 * As a complete example you could use:
 *     ```
       <div id="letters">
       	<div class="az-letters">
       		<?php the_a_z_letters(); ?><div class="clear empty"></div>
       	</div>
       </div>
       <?php if ( have_a_z_letters() ) : ?>
       <div id="az-slider">
       	<div id="inner-slider">
       		<?php while ( have_a_z_letters() ) : the_a_z_letter(); ?>
       			<?php if ( have_a_z_items() ) : ?>
       				<div class="letter-section" id="<?php the_a_z_letter_id(); ?>">
       					<a name="<?php the_a_z_letter_id(); ?>"></a>
       					<h2>
       						<span><?php the_a_z_letter_title(); ?> (<?php echo num_a_z_items(); ?> pages)</span>
       					</h2>
       					<?php while ( have_a_z_items() ) : the_a_z_item(); ?>
       						<div><ul>
       							<li><a href="<?php the_permalink(); ?>"><?php the_a_z_item_title(); ?></a></li>
       						</ul></div>
       					<?php endwhile; ?>
       					<div class="clear empty"></div>
       				</div>
       			<?php endif; ?>
       		<?php endwhile; ?>
       	</div>
       </div>
       <?php else : ?>
       	<p><?php esc_html_e( 'There are no posts included in this index.', 'a-z-listing' ); ?></p>
       <?php endif;
       ```
   
 *  Thread Starter [starflow](https://wordpress.org/support/users/starflow/)
 * (@starflow)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/add-count/#post-7345859)
 * Thanks for the additional information Daniel,
 * Just so you are aware, I am getting the following error:
 *     ```
       PHP Warning:  Division by zero in....
       ```
   
 * It comes from this line in the page template file:
 *     ```
       <?php $numpercol = ceil( num_a_z_posts() / $_a_z_listing_colcount ); ?>
       ```
   
 *  Plugin Author [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * (@diddledani)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/add-count/#post-7345860)
 * hmm, that suggests `$_a_z_listing_colcount` is `0`, when it should be at least
   1. Just to be sure, is there a line near the top of the file you modified, which
   imports that variable from the global namespace, e.g. `global $_a_z_listing_colcount;`?
 * If you’re not doing multiple-columns then you are free to remove all references
   to the columns by using the template I provided in my previous comment (that 
   template is almost identical apart from the column mechanism having been removed).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add count’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/a-z-listing_d8edfd.svg)
 * [A-Z Listing](https://wordpress.org/plugins/a-z-listing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/a-z-listing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/a-z-listing/)
 * [Active Topics](https://wordpress.org/support/plugin/a-z-listing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/a-z-listing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/a-z-listing/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Dani Llewellyn](https://wordpress.org/support/users/diddledani/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/add-count/#post-7345860)
 * Status: resolved