• Hello,

    I’m writing a plugin that requires a unique identifier if a post contains more than one instance of the shortcode.

    Here’s a shortcode function for example:

    function foo() {
    	$i = 0;
    	$i++;
    	return $i;
    	}
    add_shortcode('foo','foo');

    If I enter the shortcode twice in a post like this…

    [foo]
    [foo]

    it will return this…

    1 1

    But I would like it to return…

    1 2

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Auto-Increment a Variable Each Time a Shortcode is Called’ is closed to new replies.