Creating a reverse index for a query

I have a query loop. I would like for each item to be numbered, but in reverse order (i.e. first item’s index is the total number of results, last item’s index is 1). I can write a custom function to display the index (offset by a statically defined value) for the query (https://mangwp.com/get-index-number-in-bricks-builder-query-loop/). Also, I know that there is a dynamic tag that can display to total result count. I’m having trouble figuring out how to dynamically perform math on these two values. Unfortunately, this is the second query on the page, otherwise I could just write code to access the total count via something like $wp_query->found_posts. I feel like there must be a simple solution that I’m missing. I almost got there with a custom shortcode, but I cannot use the shortcode within a heading (which is what I need). Thanks for any advice.

You need it only for visual use? If yes, you can try css counters with counter-increment: myCounter -1;

1 Like

Yes thank you! I found basically the same solution. And the initial index can be set using inline CSS via custom Attributes, which enables the use of a dynamic tag like {query_results_count:bricksid}