Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dani Llewellyn

    (@diddledani)

    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

    (@starflow)

    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

    (@diddledani)

    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.