• tkse

    (@tkse)


    Hi.

    How should I go about including jQuery in 3.3.1? Every way I can think of either create problems with the admin-bar (hiding it) or it won’t work.

    I have Googled for other ways, but it doesn’t do anything good.

Viewing 7 replies - 16 through 22 (of 22 total)
  • Thread Starter tkse

    (@tkse)

    Or not.

    The wp_enqueue_scripts didnt fix the problem with the admin-bar.

    Chip Bennett

    (@chipbennett)

    he wp_enqueue_scripts didnt fix the problem with the admin-bar.

    Yeah. If you’re dequeueing the version of jQuery bundled with WordPress – i.e. the version of jQuery against which the Admin Bar and other core code has been tested – and enqueueing your own version of jQuery, you assume some degree of risk of breaking things – things such as the Admin Toolbar.

    Thread Starter tkse

    (@tkse)

    Back at zero then.

    Any suggestions on how I should add my own script without breaking anything then?

    Chip Bennett

    (@chipbennett)

    Any suggestions on how I should add my own script without breaking anything then?

    Is there any reason that you can’t just use the core-bundled version of jQuery?

    Thread Starter tkse

    (@tkse)

    No, not really. But how would I go about writing jQuery using that? Just throwing a script in there doesnt work so thats kind of where Im lost. ??

    In the last version of WordPress I used, I could just link to the jQuery-file in the header and write my script, which in 3.3.1 causes problems.

    Chip Bennett

    (@chipbennett)

    No, not really. But how would I go about writing jQuery using that? Just throwing a script in there doesnt work so thats kind of where Im lost. ??

    Are you trying to enqueue a jQuery library, or are you trying to write an inline script using jQuery? If you’re trying to write an inline script (e.g. for a slider or something), that should work just fine. Just be aware that WordPress uses no-conflict, so you can’t nakedly use $ as a shorthand for jQuery.

    In the last version of WordPress I used, I could just link to the jQuery-file in the header and write my script, which in 3.3.1 causes problems.

    …in which case, we’re right back where @esmi started: wp_enqueue_script().

    Thread Starter tkse

    (@tkse)

    I’m trying to write a script, but I thought I needed to get the library-file first, because when I just write a script it doesnt work.

    <script>
    jQuery(document).ready(function(){
       jQuery('.single #recent-posts-2').appendTo('.topgrid');
     });
    </script>

    …in which case, we’re right back where @esmi started: wp_enqueue_script().

    That again causes problems. :S

Viewing 7 replies - 16 through 22 (of 22 total)
  • The topic ‘Problem with including jQuery’ is closed to new replies.