Shortcode invoked multiple times
-
I have a number of custom shortcodes that end up calling functions in my mu-plugin file. I have noticed that my shortcodes are called twice during an http transaction: first via apply_filters to the content and then via apply_filters to the excerpt. This happens with a specific vendor plugin active; if this plugin is deactivated, my shortcodes are invoked once only.
My basic question is: should my shortcodes be written in such a way that they can handle being invoked more than once within a given http transaction, or should I pursue the issue with the developers of the plugin that causes this behavior.
As long as a shortcode only returns html, this is not big issue – assuming the returned html is only sent to the browser once. However, if my shortcode does other processing, such as updating a database or sending an email, these actions happen twice unless my code detects it is being invoked a second time and refrain from doing anything that second time.
Any insight is very much welcome.
Thanks
Alfred
The topic ‘Shortcode invoked multiple times’ is closed to new replies.