Wordpress Function Enqueue - I can not add Jquery in theme

0

I'm trying to add jquery to the theme, all css and js that I place in function are usually added to the code, but the jquery that is in my theme directory is not being added. The file exists in the same folder as /js/bootstrap.min.js

function enqueue_jquery() {
     // retira o jquery padrão do wordpress, ok retirou
     wp_deregister_script('jquery'); 

    // Não esta adicionando este jquery, que é o que preciso, no código
wp_enqueue_script(
    'jquery',
    get_template_directory_uri() . '/js/jquery.js',
    array(), // don't make jquery dependent on jquery...!
    '1.11.1',
    true
);

} 
add_action('wp_enqueue_scripts', 'enqueue_jquery');

function enqueue_styles_scripts() {

    //OK adicionou normal
    wp_enqueue_style(
        'style-theme',
        get_stylesheet_uri(),
        array('bootstrap-css')
    );

    //OK adicionou normal
    wp_enqueue_style(
        'bootstrap-css',
        get_template_directory_uri() . '/css/bootstrap.min.css'
    );

    //OK adicionou normal
    wp_enqueue_style(
        'stylish-portfolio',
        get_template_directory_uri() . '/css/othercss.css'
    );

    //OK adicionou normal
    wp_enqueue_style(
        'font-awesome',
        get_stylesheet_directory_uri() . '/css/font-awesome.css'

    ); 


    //Adicionou normal, mas como depende do jquery não esta funcionando
    wp_enqueue_script(
        'bootstrap-js',
        get_template_directory_uri() . '/js/bootstrap.min.js',null
    );


} 
add_action('wp_enqueue_scripts', 'enqueue_styles_scripts');


//ok adicionou normal 
function wpse_ie_conditional_scripts() { ?>
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script><scriptsrc="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <?php
}
add_action( 'wp_head', 'wpse_ie_conditional_scripts' );

?>

In the console, only the error that bootstrap.min.js depends on jquery to work appears in the console.

Thank you for your help

    
asked by anonymous 17.01.2017 / 14:06

1 answer

1

This happens because after using wp_deregister_script('jquery') it is necessary to 'register' it again before putting it back in the queue. See documentation .

So you could do something like this:

function enqueue_jquery() {
    // retira o jquery padrão do wordpress
    wp_deregister_script('jquery' ); 

    // registra o novo jquery
    wp_register_script( 
         'jquery', 
         get_template_directory_uri() . '/js/jquery.js',
         array(), 
         '1.11.1', 
         true
    );

    // enfileira o novo jquery registrado 
    wp_enqueue_script( 'jquery');
} 
add_action('wp_enqueue_scripts', 'enqueue_jquery');
    
17.01.2017 / 15:17