Filter: bricks/pagination/total_pages
The bricks/pagination/total_pages filter allows you to modify the total number of pages used in the pagination logic of Bricks Builder. In this example, we’ll demonstrate how to customize the total pages value based on custom loop results. @since 2.2
Related hooks:
bricks/pagination/custom_logicbricks/pagination/current_page
add_filter( 'bricks/pagination/total_pages', function( $total_page, $query_settings, $element ) { $query_object_type = $query_settings['query']['objectType'] ?? false;
// If not my custom loop, return original value if( $query_object_type !== 'my_custom_loop' ) { return $total_page; }
// You can access the element settings via $element->settings
// My result stored in a global variable global $my_custom_loop_results;
if ( ! $my_custom_loop_results ) { return $total_page; }
// My predefined items per page $post_per_page = 3;
return ceil( count( $my_custom_loop_results ) / $post_per_page );}, 10, 3); Was this page helpful?