Invert row counter#

By: Ronnie H | Asked: 01/04/2023
ForumsCategory: General questionsInvert row counter#
Ronnie H asked 2 years ago

Hello using the code below I was able to successfully add row counter to my view.   

 

 

add_filter('frm_display_entry_content', 'frm_get_row_num', 20, 7); function frm_get_row_num($new_content, $entry, $shortcodes, $display, $show, $odd, $atts){ if ( $display->ID == 169 ) { if ( isset($_GET['frm-page-' . $display->ID]) ) { $page_num = absint( $_GET['frm-page-' . $display->ID] ); $page_size = $display->frm_page_size; $prev_total = ($page_num - 1) * $page_size; $current_count = $atts['count'] + $prev_total; $new_content = str_replace('[row_num]', $current_count, $new_content); } else { $new_content = str_replace('[row_num]', $atts['count'], $new_content); } } return $new_content; }  

 

 

By default he numbers go from 1-10 for example, how do I invert the counter to show 10-1? Thanks 

1 Answers
Rob LeVineRob LeVine answered 2 years ago
Can you set the view to order by the number column, descending?  Use the "Sort Entries" option on the main page of the view.
Ronnie H replied 2 years ago

Thanks for the response,

When doing this "Sort Entries" only the entries change not the row # I have tried this.

Ronnie H replied 2 years ago

Descending entries goes to the top of the list but row# still reads 1.

Rob LeVineRob LeVine replied 2 years ago

Wait, you mean you want the row numbers to change dynamically when you sort them?

Ronnie H replied 2 years ago

Yes

Ronnie H replied 2 years ago

Either that or sort in descending order and just have the row numbers fixed in descending order for right now until we come up with a better solution.

Ronnie H replied 2 years ago

Hey Rob Thanks this is no longer needed I figured out a different solution.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right