How do I load external js and css files?

Community Forums Forums General Discussion How do I load external js and css files?

This topic is: not resolved

This topic contains 3 replies, has 2 voices, and was last updated by  David Chu 7 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #76564

    Ted
    Member
    Post count: 26

    I hate to ask this and feel like such a newbie it’s embarrassing, but I’m really having a hard time wrapping my head around using hooks and filters and such, so here goes. What code to I add to my functions.php to load the following css and js files?

    genesis-sample/rmm-css/responsivemobilemenu.css
    genesis-sample/rmm-js/responsivemobilemenu.js

    Please note that other people will be activating the theme and they’re even more clueless than I am. So going into the back end and adding code in the settings is not an option.

    • This topic was modified 7 months, 4 weeks ago by  Ted.
    • This topic was modified 7 months, 4 weeks ago by  Ted.
    #76617

    David Chu
    Participant
    Post count: 1318

    Hi,
    There’s no shame in not knowing hooks. It definitely takes some getting used to, but once you get it, you’re pretty much unstoppable. When I enqueue scripts, I just use a regular WordPress hook for this purpose. Here’s a sample of code that I use, adapted to your code bits. Check it and have FTP handy, as I didn’t test it. :-)

    [php]
    add_action( ‘wp_enqueue_scripts’, ‘dc_load_custom_stylesheet’, 10 );
    function dc_load_custom_stylesheet() {
    wp_enqueue_style( ‘custom-stylesheet’, CHILD_URL . ‘/rmm-css/responsivemobilemenu.css’, array(), PARENT_THEME_VERSION );
    wp_enqueue_script( ‘tedscript’, CHILD_URL . ‘/rmm-js/responsivemobilemenu.js’, array(), ’1.0′, false );
    }
    [/php]

    Cheers, Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

    #76735

    Ted
    Member
    Post count: 26

    Thanks David, now I’m unstoppable :D

    #76804

    David Chu
    Participant
    Post count: 1318

    Ted,
    Excellent! Many people will not touch code for any reason, so you’re instantly ahead of all those people!

    Other good news is that you don’t really have to be a supreme coder to do most Genesis hook-y filter-y things, just be someone willing to learn, and who uses appropriate caution, like you clearly are.

    Dave


    Dave Chu · Custom WordPress Developer – likes collaborating with Designers

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.