DCR
DCR

Reputation: 15698

wordpress shortcode for woody not working

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

Answers (1)

Cameron Hurd
Cameron Hurd

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!

  1. That the custom page is either "in WordPress" somehow, or it includes a call to require_once("../../path/over/up/to/../../wp-load.php");
  2. That you run the shortcode through the WordPress filters that will execute it! In your case <?php echo do_shortcode('[wbcr_js_snippet id="483"];'); ?>

Upvotes: 1

Related Questions