• Resolved geophray

    (@geophray)


    I am setting up a subscription site where, on a particular page, there are links to monthly content – each one of them displayed using the show content based on tags feature from Ontraport’s PilotPress Plugin.

    This is what an authenticated user with the appropriate tag would be served:

    <div class="element">
    <span class="pilotpress_protected">
    <div id="course_description_61051e32b59ab5356e3ca50a788fe763" class="course-description course-description-1">
    <img width="150" height="225" src="http://my.bravegirlsclub.com/wp-content/uploads/2014/05/E-2.png">
    <div>
    <p>September 2014 Issue</p>
    </div>
    <div class="course-description-content">
    <p>Here is the Training/Course Description</p>
    </div>
    </div>
    </span>
    <div id="ap201409">
    <img width="100%" src="http://my.bravegirlsclub.com/wp-content/uploads/2014/05/E-4-200x300.png">
    </div>
    </div>

    If the authenticated user doesn’t have the appropriate tag from Ontraport, the pilotpress protected content is not displayed/loaded, as seen below. (Note that everything in the span with class “pilotpress_protected” does not load in this instance.) I have added a div after the closing show/hide tag that will display some alternate content, but I only want it to display if the pilotpress protected content is not displayed.

    <div class="element">
    <div id="ap201409">
    <img width="100%" src="http://my.bravegirlsclub.com/wp-content/uploads/2014/05/E-4-200x300.png">
    </div>
    </div>

    Inside the show/hide tags in the first example, I’m trying to execute some jQuery that will hide the alternate content (div#ap201409).

    For some reason though, no matter what I try, I can’t get the script to work.

    Here is the content of the js file that I have enqueued in the header.

    $("document").ready(function() {
    	$('#ap201409').hide();
    });

    I’m kind of new to jquery/javascript, but have spent the last few days trying to get a grasp on it going through tutorials/etc, and by everything I have learned, this SHOULD work. But alas, it doesn’t.

    Is is possible that WordPress is blocking this script from executing? Or is the some other syntax that needs to be used inside of WordPress?

    If anyone has any other ideas why this would not be working, please advise.

Viewing 1 replies (of 1 total)
  • Thread Starter geophray

    (@geophray)

    After some more research, I figured out that to use jQuery in WordPress you have to replace the “$” with “jQuery”

    Using this as my code did the trick:

    jQuery("document").ready(function() {
    	jQuery('#ap201409').hide();
    });

    Alternatively, this also works:

    jQuery("document").ready(function($) {
    	$('#ap201409').hide();
    });
Viewing 1 replies (of 1 total)
  • The topic ‘Custom script (enqueued properly) is not running.’ is closed to new replies.