• Hi,

    Is there a way I can show the total number of images per gallery has within the post? I only use the basic thumbnails gallery.

    I’ve found some codes but none of forum says where to place the codes. Could anyone point me in a direction as to where to paste the code? Any help would be appreciated greatly!

    Below are the codes:

    <?php
    global $wpdb;
    $images = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = {$gallery->ID}") ); ?>
    <?php echo $images; ?>

    Thanks!

    https://www.ads-software.com/plugins/nextgen-gallery/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor photocrati

    (@photocrati)

    @karen11 – Can you provide any additional information? I would also suggest you look at creating a custom template to do this as well … you can find the NextGEN Legacy templates (used for customizations) here:

    ../wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/view/

    Thanks!

    – Cais.

    Thread Starter karen11

    (@karen11)

    Thanks Cais for the reply!

    Apologies if I’m not being clear. In each post, I’ll create a gallery and set Basic Thumbnail as the display type. I would love to be able to have a line of text just above the gallery to show the total number of images (example: 4 images).

    I’ve added the code:

    <?php
    global $wpdb;
    $images = intval( $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->nggpictures WHERE galleryid = {$gallery->ID}") ); ?>
    <?php echo $images; ?>

    just below

    <!-- Thumbnails -->
        <?php $i = 0; ?>
    	<?php foreach ( $images as $image ) : ?>

    in

    ../wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/view/gallery.php

    but I think I’m not doing it right.

    The closest I’ve found is someone trying to display the image count in the loop. But I’m hoping to display the image count within per gallery itself, on a post instead of within the loop. Any advice?

    I’ve checked out the custom template (hopefully I got it right) you’ve mentioned, but what I would really love is to display the gallery in Basic Thumbnail style and having the image count where the text “view slideshow” is.

    Thanks again! Any help will be greatly appreciated!

    Plugin Contributor photocrati

    (@photocrati)

    @karen11 – What is your current custom template showing? A link to where you are using it would be helpful …

    … also, you could probably just use $number_of_images = count( $images ); to get the value you are looking for. I would also suggest using a copy of the “captions” template versus the sample gallery template you are referencing.

    – Cais.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display/ show/ printf total no. of images in basic thumbnails gallery’ is closed to new replies.