Hi community,
Is there a solution/code to display the counter for loop items?
The easiest way to do this - use a css counters (Using CSS counters - CSS | MDN)
Thanks for the advice @Illarion,
I’ve done this before with CSS, but the problem is that in the loop, the value is reset when the pagination changes. Since this feature is on the idea board, I’ll wait and hope it gets added to Bricks in the near future.
never tried this, but can’t you reset it on the parent?
.wrapper {counter-reset: item;}
Then some PHP will do the trick. You can access the page number via PHP multiply by the max items per page and have a good starting point.
Any AI will help.
function get_loop_index() {
$index = intval( Bricks\Query::get_loop_index() ) + 1;
if ($index) return $index;
}
use
{echo:get_loop_index}
I don’t quite understand why this isn’t there by default. The solution is simple, but you have to add it manually each time.