• Hey guys!

    I’m working on a plugin that creates HTML Code via a shortcode.
    Now I want to identify the created HTML when the shortcode gets called twice or more often.

    Like:

    <div class="myClass-0"></div>
    <div class="myClass-1"></div>

    Is there a way to count how many times a specific shortcode got called?

    I tried this PHP code:

    if(!$count)
    {
        $count = 0;
    }
    else
    {
        $count = $count + 1;
    }

    But it seems as the variable gets deleted after calling the shortcode one time.
    I also tried global variables… But all this didn’t seem to work.

    Hope somebody can help me!
    Greets
    J.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I have the same question about this too, have you get solutions?

    thanks.

    Thread Starter julian.weinert

    (@julianweinert)

    Oh yea!
    I got the solution but forgot to answer here.

    So here you go:

    static $count;
    if(!$count)
    {
        $count = 0;
    }
    $count++;

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Shortcode Count’ is closed to new replies.