Add Metro 4 to Wordpress theme

Post Reply
User avatar
olton
Site Admin
Posts: 69
Joined: Mon Apr 09, 2018 6:19 pm
Location: Kiev, Ukraine
Status: Offline

Add Metro 4 to Wordpress theme  

Post by olton » Thu Apr 19, 2018 3:29 pm

To add Metro 4 to the WordPress theme, you must use the wp_enqueue_style and wp_enqueue_script functions and use the wp_enqueue_scripts hook:

1) open file functions.php
2) add code below to the file

Code: Select all

function metro4_scripts(){
    wp_enqueue_style('metro4_css', "//cdn.metroui.org.ua/v4/css/metro-all.min.css", array(), "4.1.16");
    wp_enqueue_style('style', get_stylesheet_uri());

    wp_deregister_script('jquery');

    wp_enqueue_script('jquery', "//code.jquery.com/jquery-3.3.1.min.js", array(), "3.3.1", true);
    wp_enqueue_script('metro4_js', "//cdn.metroui.org.ua/v4/js/metro.js", array(), "4.1.16", true);
}
add_action("wp_enqueue_scripts", "metro4_scripts");
Note the function call:

Code: Select all

    wp_deregister_script('jquery');
Calling this function overrides the default jquery. And you can include required jquery version.

It is also important: in the call to wp_enqueue_script, the last (6) parameter is true. This include javascript to the bottom of the page. If you need to include it to heade, set this parameter to false (default value).

Code: Select all

wp_enqueue_script('metro4_js', "//cdn.metroui.org.ua/v4/js/metro.js", array(), "4.1.16", true);

Post Reply