Skip Navigation

[Resolved] how to add counter to views

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 1 voice.

Last updated by rexJ-2 6 years ago.

Author
Posts
#1138886

I am trying to:
use toolset example of adding a counter to views.
Regarding this problem toolset actually refer to an example of toolset own adding custom code snippets/hacks.
https://toolset.com/documentation/adding-custom-code/count-the-number-of-views-loop-iterations/
and
https://toolset.com/forums/topic/specifying-which-view-an-incrementor-shortcode-looks-at/
But the example is not working for me!!
Please tell me how to get this function to work when apparently the

 global $loop_n; 

variable not are set and where is this global var pointing to?
So this example allways turns 0 because of

if ( !isset( $loop_n ) ) {
        $loop_n = 0;
        return $loop_n;
    }

Looking forward to see a working example or how i can correct it!
Link to a page where the issue can be seen:
https://toolset.com/documentation/adding-custom-code/count-the-number-of-views-loop-iterations/
I expected to see:
an iteration number
Instead, I got:
allways get an 0

#1138896

It depends on the view and the <wpv-loop> inserted into that.
My issue is resolved now. Thank you!