Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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>
      <script>
      $(document.body).click(function () {
      if ($("h6:first").is(":hidden")) {
      $("h6").slideDown("slow");
      } else {
      $("h6").hide();
      }
      });
      </script>
<?php woo_head(); ?>

and this is my single.php code,

`

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

`

but after doing all this thing my sidebar i.e woo_tabs is not proper you can check the image http://i52.tinypic.com/2gxe90p.jpg

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

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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..

jQuery(document).ready(function($){
    $('a#my_id').click(function () {
        if($("h6:first").is(":hidden"))
            $("h6").slideDown("slow");
        else 
            $("h6").hide();
        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.

share|improve this answer
    
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 –  ntechi Dec 3 '10 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 Dec 3 '10 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 –  ntechi Dec 3 '10 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 Dec 3 '10 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 –  ntechi Dec 3 '10 at 14:15
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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