Reputation: 15698
I'm trying to create a javascript snippet using the wordpress plugin woody but it doesn't seem to want to work. I created a snippet that just has:
(function(){
document.write(5+6);
console.log("help");
})();
I have a shortcode of [wbcr_js_snippet id="483"]; which I place in a custom page:
Code:
<div id="primary" class="site-content">
[wbcr_js_snippet id="483"];
<div id="content" role="main">
<?php
print_r($_POST);
if(isset($_POST["place"]) && $_POST["place"] === "foot") $place="foot";
else if(isset($_POST["place"]) && $_POST["place"] === "involved")$place="involved";
else $place="home";
echo $place;
?>
</div><!-- #content -->
</div><!-- #primary -->
This will work if I set it to automatic insertion but trying to use the shortcode doesn't work
Upvotes: 0
Views: 628
Reputation: 5031
If you place a WordPress shortcode in a custom page, you have to to ensure at least two things in order for it to work!
require_once("../../path/over/up/to/../../wp-load.php");
<?php echo do_shortcode('[wbcr_js_snippet id="483"];'); ?>
Upvotes: 1