0

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!

0

I have solved my issue by using a more recent version (1.1.1) of Elementor Custom Skin Pro plugin, which allows to use dynamic values directly in the template content, that are interpreted during the Loop. In my case, {{index}} does the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.