If you want it to show on 3-rd website, wich is not wordpress or isn’t using your plugin than the only way is to use iframe
Aldought there might be better solutions, i would do it these way:
- Create ajax action (
wp_ajax_nopriv_....
) - in callback write the code that should echo ( your shortcode ). see example under a list
- add some feature that will generate url and redirect it to your ajax calls, for ex. instead of
yoursite.com/wp-admin/admin-ajax.php?action=iframe&arg1=test
you’ll have something likeyoursite.com?blahblah
wich in.htaccess
orphp
will redirect it to ajax url ( the first one ) [ these step is not nesseccery ] - Provide your visitors an link builder or something like it, so they could just copy-paste embedded code
The callback ex.:
$arg1 = $_GET['arg1']; // get all variables that cann be used in shortcode
?>
<html><head>....</head><body><?php echo do_shortcode( '[your_shortcode arg1="' . $arg1 . '"]' ); ?></body></html>
<?php die();
in head, or before </body>
you should do wp_enqueue_script( 'your_script' ... )
and wp_enqueue_style( 'your_style' .. )
related to your shortcode, for their proper look atc.
And generated code ( without 3 step ) should look like these:
<iframe src="http://yoursite.com/wp-admin/admin-ajax.php?action=iframe&arg1=test"></iframe>
And it should show your shortcode on every website