I am using both of PHP snippet and WPdatatables. When I want to use wpdatatable shortcut code in any wordpress html page it is working. But When I want to use this code inside any PHP code or Javascript like the following examples its NOT WORKING, just printing shortcut text to the screen or not getting JS variable value instead of the correct wpdata tables content. Is there any solution, thanks.
PHP usage example
echo "<br><br> [wpdatatable id=6 ]";
JS usage example
document.write('[wpdatatable id=6]');
HTML + JS example
[wpdatatable id=6 var1=<script> let urlParams = new URLSearchParams(window.location.search);
let pid= urlParams.get('pid');
document.write('pid');
</script>]
Shortcodes in WordPress are bits of text you can use in the content area to invoke some kind of function to accomplish certain tasks. You can write your own shortcodes, and plugins often offer their functionality via shortcodes as well.
But what if you want to use a shortcode from within a template instead of with the content of a Post/Page? You can invoke it with a special function:
<?php echo do_shortcode("[shortcode]"); ?>
This won't be easy as shortcodes only work on server side and javascript code runs in browser and not on your server.
Hi to all,
I am using both of PHP snippet and WPdatatables. When I want to use wpdatatable shortcut code in any wordpress html page it is working. But When I want to use this code inside any PHP code or Javascript like the following examples its NOT WORKING, just printing shortcut text to the screen or not getting JS variable value instead of the correct wpdata tables content. Is there any solution, thanks.
PHP usage example
JS usage example
HTML + JS example
let urlParams = new URLSearchParams(window.location.search); let pid= urlParams.get('pid'); document.write('pid'); </script>]
Hi Ozgur,
Thank you for your purchase.
Shortcodes in WordPress are bits of text you can use in the content area to invoke some kind of function to accomplish certain tasks. You can write your own shortcodes, and plugins often offer their functionality via shortcodes as well.
But what if you want to use a shortcode from within a template instead of with the content of a Post/Page? You can invoke it with a special function:
This won't be easy as shortcodes only work on server side and javascript code runs in browser and not on your server.
Please check these references:
http://stackoverflow.com/questions/16304706/wordpress-outputting-shortcode-with-javascript
http://wordpress.stackexchange.com/questions/64010/call-shortcode-in-javascript
Best regards.
Kind Regards,
Isidora Markovic
wpDataTables: FAQ | Facebook | Twitter | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Amelia demo sites | Docs
You can try our wpDataTables add-ons before purchase on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables