Site logo

[Support request] How to add jquery if not using the sticky navigation module

Home Forums Support [Support request] How to add jquery if not using the sticky navigation module

Home Forums Support How to add jquery if not using the sticky navigation module

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2279639
    Gary

    Hi Support

    Hopefully a simple request, I want to use an Elements hook to enqueue jquery on a couple of pages using a slider which still requires jquery.

    By default the slider doesn’t work because GP isn’t including jquery as I’m not using the sticky nav which I believe is the only thing in GP that still requires jquery.

    So what is the best way to add jquery manually for a couple of pages? I’ve found this code mentioned in previous threads but it doesn’t seem to work for me:

    add_action( 'wp_enqueue_scripts', 'tu_load_jquery' );
    function tu_load_jquery() {
        wp_enqueue_script( 'jquery' );
    }

    Thanks

    #2279688
    Leo
    Staff
    Customer Support

    Hi there,

    That code should still work.

    Can you make sure that it’s added using one of these methods?
    Adding PHP: https://docs.generatepress.com/article/adding-php/

    #2279735
    Gary

    Hi Leo

    Is there a reason I shouldn’t use an Element hook for this with tge execute php option checked?

    That’s what I’m doing currently.

    Thanks

    #2279736
    Leo
    Staff
    Customer Support

    Hmm because it’s a function and not a hook content.

    #2279741
    Gary

    OK sorry, should have made myself clearer, I am using a hook element set to wp_footer in this case, which I’m trying to then enqueue jquery with using the snippet mentioned above. That should work correct?

    Thanks

    #2279813
    Ying
    Staff
    Customer Support

    No, your method would work if the PHP code outputs content or if it’s a script.

    But it’s a PHP function, it should be added using one of the methods introduced here:https://docs.generatepress.com/article/adding-php/

    #2279875
    Gary

    Hi Ying

    OK thanks for clarifying. In that case I’ll use the snippets plugin.

    Thanks

    #2279931
    Ying
    Staff
    Customer Support

    No problem 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.