javascript - I am converting a Bootstrap theme into Wordpress but I cannot get my scripts to load in and run -
here repos on github theme: https://github.com/ryanchrist4/ryanstrap
what have done removed script tags head , put them functions.php file using wp_register_script function , wp_enqueue_script function. have looked @ answers other peoples similair questions , tried formatting them still cant scripts run. new web development , new wordpress. also, in header, there script tag calling multiple function error in console says "uncaught reference error.
here code in functions.php file:
<?php //jquery insert google if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue"); function my_jquery_enqueue() { wp_deregister_script('jquery'); wp_register_script('jquery', "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null); wp_enqueue_script('jquery'); } //launches of scripts below add_action("wp_enqueue_scripts", "launch_scripts"); function launch_scripts() { wp_enqueue_script('the-flexslider', get_template_directory_uri() . '/assets/js/jquery.flexslider-min.js'); wp_enqueue_script('the-fitvids', get_template_directory_uri() . '/assets/js/jquery.fitvids.js'); wp_enqueue_script('the-smoothscroll', get_template_directory_uri() . '/assets/js/jquery.smooth-scroll.min.js'); wp_enqueue_script('the-backstretch', get_template_directory_uri() . '/assets/js/jquery.backstretch.min.js'); wp_enqueue_script('the-bootstrap', get_template_directory_uri() . '/assets/js/bootstrap.js'); wp_enqueue_script('the-bootstrapmin', get_template_directory_uri() . '/assets/js/bootstrap.min.js'); wp_enqueue_script( 'the-gmaps', get_template_directory_uri() . '/http://maps.google.com/maps/api/js', array(), '20120206', true ); wp_enqueue_script('the-mgmaps', get_template_directory_uri() . '/assets/js/gmaps.js'); wp_enqueue_script('the-script', get_template_directory_uri() . '/assets/js/script.js'); } ?>
here content of header.php file:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1" /> <!-- not valid html works --> <title><?php bloginfo( 'title' ); ?></title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="description" content="a admin theme" /> <meta name="author" content="ahthemes" /> <!--<script>menu(); backstretch(); slider(); contentslider(); map(); panels(); blogposts();</script>--> <!-- le styles --> <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>"media="screen" /> <!-- html5 shim, ie6-8 support of html5 elements --> <!--[if lt ie 9]> <script src="assets/js/html5shiv.js"></script> <script src="assets/js/respond.min.js"></script> <![endif]--> <!--[if gte ie 9]> <style type="text/css"> .gradient { filter: none; } </style> <![endif]--> <!-- fav , touch icons --> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png"> <link rel="shortcut icon" href="assets/ico/favicon.png"> <?php wp_head(); ?> </head> <body> <div class="nav-section"> <ul class="nav"> <li><a href="#home" class="scroll home">home</a></li> <li><a href="#about" class="scroll about">about</a></li> <li><a href="#work" class="scroll work">work</a></li> <li><a href="#contact" class="scroll contact">contact</a></li> </ul> </div>
this sounds javascript issue, compounded wordpress.
generally, when mentions "uncaught reference error" has scripts depending on something, , thing not being loaded yet.
that's hunch. that, code should changed following -- cleaned code :-)
also fixed code errors, have 1 of external scripts being loaded in badly (the gmap thing).
<?php // replace core jquery version 1.7.1 (bootstrap theme requirement) // wordpress 4.5 includes 1.12.3 // when not within administration area of wordpress. if (!is_admin()) { add_action("wp_enqueue_scripts", "replace_jquery"); } function replace_jquery() { wp_deregister_script('jquery'); wp_register_script('jquery', "//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, '1.7.1', false); wp_enqueue_script('jquery'); } // load of scripts below, on every single page. :-\ add_action("wp_enqueue_scripts", "launch_scripts"); function launch_scripts() { $internal_path = get_template_directory_uri() . '/assets/js/'; wp_enqueue_script('the-flexslider', $internal_path . 'jquery.flexslider-min.js', array('jquery')); wp_enqueue_script('the-fitvids', $internal_path . 'jquery.fitvids.js', array('jquery')); wp_enqueue_script('the-smoothscroll', $internal_path . 'jquery.smooth-scroll.min.js', array('jquery')); wp_enqueue_script('the-backstretch', $internal_path . 'jquery.backstretch.min.js', array('jquery')); wp_enqueue_script('the-bootstrap', $internal_path . 'bootstrap.js', array('jquery')); wp_enqueue_script('the-bootstrapmin', $internal_path . 'bootstrap.min.js', array('jquery')); wp_enqueue_script('the-gmaps', '//maps.google.com/maps/api/js', array('jquery'), '20120206', true); wp_enqueue_script('the-mgmaps', $internal_path . 'gmaps.js', array('jquery')); wp_enqueue_script('the-script', $internal_path . 'script.js', array('jquery')); } ?>
Comments
Post a Comment