If you’re using a class, it would be
class MyShortcode {
static $instance = 0;
function __construct($args = array()) {
add_action( 'init', array(&$this, 'init') );
}
function init() {
add_shortcode('myshortcode', array(&$this, 'shortcode'));
}
static function shortcode($atts) {
//this is the code of your shortcode
// you can increment your counter
self::$instance++;
}
}
Related Posts:
- Change appearance of shortcode text inside editor
- Using preg_replace to separate gallery from the_content?
- Remove specific shortcode from get_the_content()
- shortcode not working and the relation to the_content()
- has_shortcode for content added after the content
- shortcode causing the_content() to return blank?
- Visual Composer integration [closed]
- How to split text text text into array
- Adding to the_content or a variable from within a shortcode function
- Execute Closing Shortcode After the_content
- Single post content custom order
- find shortcode inside content of post
- Add shortcode within the_content()
- Checking post content for a shortcode, but content is being returned as empty
- Global $post returns 2 objects for my shortcode
- the_content() not showing the content in good order (with a shortcode)
- Using shortcode to stop post content from displaying
- Shortcode append to the the_content()
- Create a shortcode to display the “the_content ()” in my post [closed]
- Nested ShortCode works inside the_content, but not outside of it
- Conditionally Loading JavaScript/CSS for Shortcodes
- shortcodes output before content [duplicate]
- WordPress adds br in between my shortcode
- Shortcodes, HTML tables, and multiple rows
- Does a shortcode with a single attribute have to use an array?
- Shortcode to Gutenberg-block: additional text on front-end and conditional display
- How navigation works in custom loop within shortcode?
- conditional shortcode not working
- Shortcode But Without The Equals Sign?
- Shortcode output is screwed up when arrow symbol “
- How best to apply do_shortcode in media.php for captions
- shortcodes between square and curly brackets
- Searching in shortcode contents
- Applying filters to the_content() to separate content if any `add_shortcode()` is found?
- Wp_localize_script from Shortcode [closed]
- Localization inside shortcode not working
- Get shortcode attribute outside of WordPress
- Overriding shortcode $atts for featured products
- How to create a shortcode for embedding pdf in iframe?
- Woocommerce, ordering products by default on shortcode pages
- Looking for a way to include/embed text from a file on a page so that the short codes are processed
- Gravity forms customize field markup for the same form appearing in different places
- How to force that styles are enqueued in the header?
- Edit shortcode in post content programatically
- How to change to local video player on shortcode ultimate to video.js?
- show shortcodes in editor
- Image Shortcode from ACF ID
- Page code showing in WP Dashboard
- echo do_shortcode just prints the shortcode name and not its content
- How to create a shortcode with html and php code
- Insert shortcode between ”
- Create a shortcode to use in visual editor
- Custom youtube shortcode that uses $content
- How to build dynamic pages?
- Shortcode not showing $content in correct place
- How to reload the shortcode content when the database is changing
- Best way to include reusable sections in page content
- Custom shortcode to display posts, first post is full
- How to add data attributes to the wordpress audio shortcode
- Beginner’s question about shortcodes
- How to execute a shortcode outside the post content/entry in a theme?
- Metabox Keeps Stripping Parts of Shortcode
- Shortcode from admin textarea to page
- Form processing: How to process form before output and access data from shortcode
- How to Retrieve data of Gallery Shortcode and display it above a post
- get data with shortcode
- Replace shortcode with output in database?
- Wrap php in shortcode
- Adding my own custom woocommerce shortcode to child theme, how?
- contact form 7 :create shortcode usable in email message [closed]
- Iteratively add sub shortcodes to php array
- Shortcode, Concatenating & Parse error: syntax error, unexpected T_FOREACH
- Better way to display multiple plugin output on the same page?
- Getting Shortcode Attributes befor content is displayed by the template
- Shortcode won’t take into account custom post ID put in parameter
- Colon is Missing In My Website Url in WordPress Shortcode
- Shortcode not working inside div html
- How to utilise multiple values from a single shortcode attribute?
- JavaScript missing from shortcode content
- Multiple shortcodes with embedded JavaScript code in same page, how?
- Contact Form 7 shortcode is commented out, but I receive spam emails from it
- How to load specific template page in a custom shortcode
- WordPress keeps automatically inserts
- nested shortcodes from different plugins. too complex? [duplicate]
- How to make shortcode enabled in JSON Feeds?
- How to add a shortcode to an HTML image tag
- Shortcode or Template Page
- Why can’t I type [ ] opening and closing brackets on the Visual tab?
- Shortcode for External HTML
- How to implement theme shortcodes in text outside of pages?
- load plugin with ajax [duplicate]
- Shortcode Attribute
- Can not get shortcode content in function
- Question about do_shortcode
- Enclosing shortcodes create line breaks
- Add the results of a custom query into a do_shortcode
- wordpress shortcode url decode non Latin character
- Shortcode return vs echo. Return messes with data URLs, echo does not
- How do I create a shortcode that returns a logged in users’ email?
- shortcode causes broken paragraph tags