1
votes

I'm making a WordPress theme, I'm new to WordPress but know a lot about HTML, CSS, JavaScript, jQuery and PHP.

The problem is the theme I'm creating is not loading plugin js files.

Here the my header code:

<!DOCTYPE HTML>
<html>
<head>
<title>
            <?php 
                wp_title('|','true','right');
                bloginfo('name');
            ?>
            <meta charset="<?php bloginfo( 'charset' ); ?>">
            <meta name="viewport" content="width=device-width">

        </title>
        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
        <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('template_url')?>/css/reset.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('template_url')?>/css/bootstrap.min.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('template_url')?>/css/grid.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo bloginfo('template_url')?>/style.css" />

        <script type="text/javascript" src="<?php echo bloginfo('template_url')?>/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo bloginfo('template_url')?>/js/bootstrap.min.js"></script>

        <?php
            wp_head();
        ?>
    </head>
    <body>
        <div class="container">
            <div class="main-nav row" id="show-nav">
                <a href="javascript:;">Navigation</a>
            </div>
            <div class="main-nav row" id="close-nav">
                <a href="javascript:;">Close Navigation</a>
            </div>
            <div class="row nav-bar">
                <?php

                    wp_nav_menu(array('container_class'=>'main-nav','container'=>'nav'));

                ?>
            </div>

i'm loading jquery manually but i tried to load jquery with wordpress functions.

also tried this code,

if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
   wp_deregister_script('jquery');
   wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
   wp_enqueue_script('jquery');
}

but didn't working. i have tried many plugins, but just js files of plugins not loading so no plugins working.

I have tried metaslider plugin and Easy Image Gallery plugin. both works in Wordpress default theme but not in mine, because of js file.

2
registering your script as jquery may conflict with the default script names that are built into wordpress.. I would consider changing your enqueue_script function name with something that is not on the list by the way. codex.wordpress.org/Function_Reference/wp_register_scriptRobert Lee

2 Answers

2
votes

Didn't include wp_footer function before closing body tag, it worked with wp_footer function.

0
votes

Can you try add it on function.php, for example:

wp_register_script('jquery-ui', get_template_directory_uri().'/js/jquery-ui.js');
wp_enqueue_script('jquery-ui');