I'm using Elementor 2.6.8 + Elementor Pro 2.6.2
I'm designing an Archive template to display a list of Custom Post Types filtered by custom taxonomy terms. I'm using Posts Widget from Elementor Pro to do this without a line of code.
Also, thanks to Ele Custom Skin plugin (1.2.0), I can design each post skin in a custom way (hopefully Elementor Pro will provide this in the future)/
Now, I want to display, in each post, the post's current position in the list (=in the WP loop).
I tried with this code snippet that I added to each post with the ShortCode Widget.
add_shortcode( 'current_post_count', function () {
global $wp_query;
$out = $wp_query->current_post;
return $out;
} );
But this always return -1.
I suppose the reason is that, in the context of the Posts Widget, the global $wp_query is not the one to get the info from. I suppose the widget use another variable. But thenm I don't know how to achieve this. Maybe if I could get the actual $query variable in use ? Or maybe use the Query ID parameter offered by the Posts Widget?
I don't know how to get this to work.
Anything to point me towards the right direction guys? thanks!