Output format specific shortcode

Maybe I’ve missed the feature but I could not find anything like this in the documentation. Is there a way to have different shortcodes according to the output format? I’m currently trying to implement AMP pages and the standard is very strict as regards what html tag is allowed and what isn’t. Because of that, I have several shortcodes that break because they contain javascript for example.

Is there a way to either:

Implement two versions of the shortcode, ex myshortcode.html and myshortcode.amp.html
Programmatically know in the shortcode if it will be outputing in a HTML or AMP file.

Nevermind, I dont know how I missed it the first time I tried but it IS possible to have output-specific shortcode like AMP using the naming convention myshortcode.amp.html

Would be great if the documentation was referring it.

1 Like