Skip Navigation

[Résolu] Display item-number in views

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 2 réponses, has 2 voix.

Last updated by dianaM-4 Il y a 4 années et 8 mois.

Assigned support staff: Minesh.


Hi all!
I'm wondering, if there is a quick way to display the index-number of an item in a list-view. Just like:

<!-- wpv-loop-start -->
    <div id="block-[wpv-item-indexnumber]">
        This is my [wpv-item-indexnumber]. post.
<!-- wpv-loop-end -->

Is there an API or a shortcode for that?



Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

No there is no such shortcode available with Toolset. You may try to use [wpv-item] shortcode with "index" attribute:

For example:

    [wpv-item index=1]
      your output 
    [wpv-item index=2]
      your output
    [wpv-item index=other]
      your output

More info:
[Section: "Loop parameters & wpv-item : wrap, pad, pad-last, index"]


Add these lines to functions.php in your theme folder:

add_shortcode('incrementor', 'incrementor');
function incrementor() {
static $i = 1;
return $i ++;

Then define your View template as:

<li class="block-[incrementor]"> 
your content

But - if your need is to make ids unique then you can use [wpv-post-id]. For example

<li class="block-[wpv-post-id]"> 
your content

Thanks Minesh,
that helped a lot! I used your php-shortcode and it works perfectly!
Best regards, Diana

(I needed a fixed ID, that stays the same on all translated pages. So in this case the post-ID or post-slugs didn't work for me ...)