• Resolved amistad18

    (@amistad18)


    Hey,

    I found a problem with gallery pagination, which is working like this:

    $pages = intval( $count_all_albums / $per_page );
    if ( $count_all_albums % $per_page > 0 )
    	$pages += 1;
    $range = 100;
    if ( ! $pages ) {
    	$pages = 1;
    }
    if ( 1 != $pages ) {

    So if there is less galleries than it is allowed to display on one page – there is no need for pagination, fair enough. But the issue in my case was that variable $count_all_albums was always 0, so the pagination didn’t appear even when it should.

    I found why, in file:

    template/gallery-template.php

    On line 31, I found:

    $count_all_albums = $wpdb->get_var( "SELECT COUNT(*) FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'gallery' AND (wp_posts.post_status = 'publish')" );

    I was quite surprised when I found this out 🙂 You’re using $wpdb, but even so, in query you put hardcoded table names. You know that a loooot of websites do not use wp_ prefix anymore? 🙂

    I even have a fix for you:

    $count_all_albums = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE 1=1 AND $wpdb->posts.post_type = 'gallery' AND ($wpdb->posts.post_status = 'publish')" );

    Cheers.

    https://wordpress.org/plugins/gallery-plugin/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author bestwebsoft

    (@bestwebsoft)

    Hi,

    We have received your query and it is now being processed. We will get back to you on this forum as soon as we can.

    Regards,
    BestWebSoft Support Team

    Plugin Author bestwebsoft

    (@bestwebsoft)

    Hi,

    Thank you for contacting us.
    We are aware of this problem. It is a bug of our plugin, and we will fix it in the next update.

    Regards,
    BestWebSoft Support Team

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Gallery pagination issue’ is closed to new replies.