0

So I'm converting a html template to a wordpress theme, I've added all the specific tags in the index.php, footer.php, header.php, and style.css and it looks my scripts won't load properly. This is the site that I want to convert : http://iulian.cablevision.ro/rock4life/ I've instaled wordpress on my localhost to play in the sandbox. And I think the problem is withing the functions.php ? this is how my website loads: http://iulian.cablevision.ro/rock4life_wp/ . I also removed the loading screen at the begining because won't load the site at all... Inspecting whit firebug will show up no scripts. function.php file:

<?php

function firstwp_resources(){
    wp_enqueue_style('style', get_stylesheet_uri());
}

add_action('wp_enqueue_scripts','firstwp_resources');

   function your_scripts() {
                    wp_register_script('jquery', 'js/jquery.js', true);
                    // This registers your script with a name so you can call it to enqueue it
                    wp_enqueue_script( 'jquery' );
                    // enqueuing your script ensures it will be inserted in the propoer place in the header section
                    wp_register_script('jquery.reveal', 'js/jquery.reveal.js', true);
                    wp_enqueue_script( 'jquery.reveal' );

                    wp_register_script('jquery.backstretch', 'js/jquery.backstretch.min.js', true);
                    wp_enqueue_script('jquery.backstretch');

                    wp_register_script('jquery.tweet', 'js/jquery.tweet.js', true);
                    wp_enqueue_script('jquery.tweet');

                    wp_register_script('mediaelement-and-player', 'js/mediaelement-and-player.min.js', true);
                    wp_enqueue_script('mediaelement-and-player');

                    wp_register_script('custom', 'js/custom.js', true);
                    wp_enqueue_script('custom');

                    wp_register_script('jquery.placeholder', 'js/jquery.placeholder.min.js', true);
                    wp_enqueue_script('jquery.placeholder');
            }
            add_action('wp_enqueue_scripts', 'your_scripts');
            // This hook executes the enqueuing of your script at the proper moment.
1
  • 2
    Look at the documentation for wp_register_script(). (1) the second parameter should be a full URL; (2) WordPress pre-registers lots of standard scripts, for example jQuery. Commented Mar 3, 2015 at 18:42

1 Answer 1

1

This will make sure the scripts to load, and will make sure the scripts for the Dashboard to be safe.

<?php
function firstwp_resources() {
    if (!is_admin()) {

        // Default Scripts
        wp_deregister_script('jquery');
        wp_register_script('jquery', get_template_directory_uri().'/assets/js/jquery.js', false, null);
        wp_enqueue_script('jquery');

        wp_deregister_script('jquery-mig');
        wp_register_script('jquery-mig', get_template_directory_uri().'/assets/js/jquery-mig.js', false, null);
        wp_enqueue_script('jquery-mig');

        // Other Scripts
        wp_enqueue_script('name', get_template_directory_uri().'/assets/js/name.js', false, null, true); // loads in footer
    }
}
add_action('wp_enqueue_scripts', 'firstwp_resources');
?>

Default Scripts Included and Registered by WordPress

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.