i'm working on wordpress theme using bootstrap on localhost. have load css files correctly , have load js files using right way reasons js scripts not working.
here index.php
<?php get_header(); ?> <?php get_footer(); ?> here header.php
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href = "<?php bloginfo(stylesheet_url); ?>" rel = "stylesheet"> </head> <body> <!-- navigation --> <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">start bootstrap</a> </div> <!-- collect nav links, forms, , other content toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li> <a href="#about">about</a> </li> <li> <a href="#services">services</a> </li> <li> <a href="#contact">contact</a> </li> </ul> </div> <!-- /.navbar-collapse --> </div> <!-- /.container --> </nav> here footer.php
<script src= "<?php get_template_directory(); ?>/js/bootstrap.js"></script> </body> </html> this problem drives me crazy! spent 2 hours searching solution nothing!
so problem guys?
you can use including scripts
function wm_scripts(){ wp_register_script( 'jscript', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' ); wp_register_script('bootstrapjs',get_template_directory_uri() .'/js/bootstrap.min.js'); wp_enqueue_script( 'jscript' ); wp_enqueue_script( 'bootstrapjs' ); } add_action( 'wp_enqueue_scripts', 'wm_scripts' ); and stylesheet have use function.
function wm_css(){ wp_register_style( 'bootstrapgrid', get_template_directory_uri() . '/css/bootstrap.min.css' ); wp_enqueue_style( 'bootstrapgrid' ); } add_action( 'wp_enqueue_scripts', 'wm_css' ); please refer wordpress documentation include script footer. right way include script , styles. , please add wp_head(); functions in header load script , styles.
Comments
Post a Comment