Post Grid Load More not working with RAND Sort
-
If you use random sort (offset == 0, limit == 8, number of posts in backend == 12) in a post grid with load more button, the load more button is not working.
This is because of the SQL created in /wp-content/plugins/essential-addons-for-elementor-lite/includes/Traits/Helper.php line 72.
I added an if statement around:
if(empty($args[ 'orderby' ]) || $args[ 'orderby' ] != 'rand') { $args[ 'offset' ] = (int)$args[ 'offset' ] + ( ( (int)$_REQUEST[ 'page' ] - 1 ) * (int)$args[ 'posts_per_page' ] ); } else { unset($args[ 'offset' ]); }
because RAND sorting with post__not_in will already exclude the posts you don’t want to see anymore. A offset for the query is not needed anymore (in fact, it will not show the next posts).
my change with make the “LIMIT 8,8” in the sql to “LIMIT 8”.
- The topic ‘Post Grid Load More not working with RAND Sort’ is closed to new replies.