i have a form which is displayed after every post, so i coded it in single.php, but the form is too long so i thought of putting it in jquery section, where if the user wants then he/she can click on open and the form will slide down for this purpose i used slide up/down jquery http : //api . jquery . com/slideDown/

I integrated the jquery in proper order in header.php, here is my header.php jquery code

<?php wp_enqueue_script("jquery"); ?>
<?php wp_head(); ?>
<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/functions/js/jquery-1.4.4.js"></script>
      $(document.body).click(function () {
      if ($("h6:first").is(":hidden")) {
      } else {
<?php woo_head(); ?>

and this is my single.php code,

<div class="post">
     <?php echo do_shortcode("[contact-form 2]"); ?></h6>

but after doing all this thing my sidebar i.e woo_tabs is not proper:

enter image description here

here my woo tabs instead of coming side by side, it is coming down, is my code right?

1 Answer 1


Trim your above code down to..

<?php wp_enqueue_script( "my_script", plugins_url( '/your-script-name.js', __FILE__ ), array( 'jquery' ) ); ?>
<?php wp_head(); ?>
<?php woo_head(); ?>

Place your jQuery into a JS file, then enqueue it with jQuery as a dependancy(as above), this will ensure jQuery is loaded before your script is. Your script also needs to use a no-conflict wrapper, and should be updated to read..

    $('a#my_id').click(function () {
        return false;

Or something to that degree..

NOTE: This is wrong..

<?php wp_enqueue_script("jquery"); ?>
<script type="text/javascript" src="<?php bloginfo("template_url"); ?>/functions/js/jquery-1.4.4.js"></script>

By doing that you're instructing WordPress to load the included version of jQuery, and then also including your own, so essentially you're loading two versions of jQuery(you only need one, i'd suggest the one WordPress ships with - per above suggested code).

Hope that helps.. :)

EDIT: jQuery updated inline with request in comments.

Accompanying HTML for link to work inline with jQUery.

<a id="my_id" href="#showform">My Special Link</a>

NOTE: I'm still unclear exactly what this jQuery needs to do for you, so i've simply updated the code posted earlier, i hope that's what you're aiming for... else please please clarify with more details.

  • hey it worked, thanks for the help, but i just want that when the person clicks on the link or a text then only the jquery works Commented Dec 3, 2010 at 12:13
  • Sorry i'm not sure what you mean, can you clarify what the intended behaviour please. "the link" "a text", no idea what either of those refer to, please explain in as much detail as possible. Please add any additional information to your original question.
    – t31os
    Commented Dec 3, 2010 at 12:17
  • normally the form or the jquery is working when i click anywhere in the page, but i want that the jquery should work only when someone clicks on something Commented Dec 3, 2010 at 12:59
  • Well yes that will happen, it's been attached to the body of the page, what element do you want it attached to? More details please..
    – t31os
    Commented Dec 3, 2010 at 14:07
  • i just want that, there should be a text or a link kind of thing where if you just click on that, the jquery will work for example "For registration form CLICK HERE" if the user clicks on CLICK HERE then the form should come Commented Dec 3, 2010 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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