Paging broken in get_gallery function
-
I am calling the get_gallery function from some of my code in order to get the top 4 images from a specific gallery.
I noticed it has a handy $limit argument, but when I set this to 4 I get the following PHP error:
Using $this when not in object context in <path>/wp-content/plugins/nextgen-gallery/lib/ngg-db.php on line 243
I fixed this by changing the following lines to change references to $this to $result instead:
// Count the number of images and calculate the pagination if ($limit > 0) { $result->paged['total_objects'] = intval ( $wpdb->get_var( "SELECT FOUND_ROWS()" ) ); $result->paged['objects_per_page'] = max ( count( $result ), $limit ); $result->paged['max_objects_per_page'] = ( $limit > 0 ) ? ceil( $result->paged['total_objects'] / intval($limit)) : 1; }
But every time I upgrade the plugin I lose this fix and have to do it again.
Can someone fix it in the codebase please?
- The topic ‘Paging broken in get_gallery function’ is closed to new replies.