Code in question here: http://pastebin.com/PN29WKNq

It worked on the HTML page I tested it on. Its supposed to add "display: none" to the content divs and then add "display: block" when the appropriate tab is clicked. But it just changes to "display: none" and never changes.

  • 1
    Just a quick note : did you try the noConflict mode ? It's safer to use jQuery instead of the $ in your jQuery code, as WP uses it too.
    – Simon
    Feb 1 '12 at 21:40

WordPress automatically loads jQuery in "no conflict" mode so that it will be compatible with other libraries. This means the $ variable isn't used for jQuery within WordPress.

Rewrite your code to use the full jQuery keyword when you begin your closure like this:

jQuery(document).ready(function($) {

    // ... other code in here


This is functionally the same as $(document).ready(function() { but uses the full name of the jQuery object to avoid noConflict issues. By passing jQuery in to the closure as the $ variable you can then use $ like normal inside the closure.

  • I updated my code to this: jQuery(document).ready(function($) { ... but it still doesn't work. I have no doubt thats what you're supposed to do but the jquery isn't working the way it did on the html page
    – pope
    Feb 1 '12 at 22:05
  • Are you enqueueing jQuery? I can't see your full script ... so all I can help troubleshoot is what I have access to.
    – EAMann
    Feb 1 '12 at 22:14
  • The full script is what I showed you in the pastebin. Its the only script I have.
    – pope
    Feb 1 '12 at 22:14
  • No, I mean all of your code. All of the PHP and JS you're using to try to use this. The code you showed in the pastebin had both JS and PHP cobbled together and didn't show where you were using what.
    – EAMann
    Feb 1 '12 at 22:18
  • What part of the theme do you need to see? Its all pretty standard. The PHP code is from my functions.php for a shortcode and the jQuery is in its own main.js file.
    – pope
    Feb 1 '12 at 22:20

Try putting this in your functions.php file in your theme folder:

function load_jquery() {
    if (!is_admin()) {

        wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.5/jquery.min.js', false, '1.8.5');
add_action('init', 'load_jquery');

You could also use this plugin: http://wordpress.org/extend/plugins/use-google-libraries/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.