Correct way to pass information between seperate shortcode functions

The correct way is not to do it. Shortcodes are supposed to be self contained and represent an insertion point to some complicated HTML that is harder to get right or due to security permissions is impossible to insert in its pure HTML form.

Globals are hated magic when you write proper code, now think about plain text, how exactly the non technical writer can even guess that one shortcode is depending on the other, and what will be the result of removing one of them?

if the second shortcode needs to know the attributes passed to the first, just document that the user should pass the same parameters to both.

Leave a Comment