Adding Javascript Functions to Header.php
-
I am working on a theme and adding javascript directly to the header. When I add just two functions the pages work beautifully, but when I add all of the functions I need all javascript stops working. Why does it not work with more than two functions?
Here is the header code after I add all the javascript:<!doctype html> <html <?php language_attributes(); ?> class="no-js"> <head> <meta charset="<?php bloginfo('charset'); ?>"> <title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' :'; } ?> <?php bloginfo('name'); ?></title> <link href="//www.google-analytics.com" rel="dns-prefetch"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="<?php bloginfo('description'); ?>"> <?php wp_head(); ?> <?php if( is_category() ) { ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" /> <?php } ?> <?php if( is_front_page() ) { ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" /> <?php } ?> <?php if( is_home() ) { ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" /> <?php } ?> <?php if( is_page() ) { ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" /> <?php } ?> <?php if( is_archive() ) { ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" /> <?php } ?> <?php if( is_single() ) { ?> <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/style.css" /> <?php } ?> <script> conditionizr.config({ assets: '<?php echo get_template_directory_uri(); ?>', tests: {} }); function openNav() { document.getElementById("mySidenav").style.width = "25vh"; } function closeNav() { document.getElementById("mySidenav").style.width = "0"; } function myFunction1() { document.getElementById("extra").style.display = "block"; } function myFunction2() { document.getElementById("extra2").style.display = "block"; } function myFunction3() { document.getElementById("extra3").style.display = "block"; } function myFunctionC() { document.getElementById("extra").style.display = "none"; } function myFunctionC2() { document.getElementById("extra2").style.display = "none"; } function myFunctionC3() { document.getElementById("extra3").style.display = "none"; } </script> </head> <body <?php body_class(); ?>>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
The topic ‘Adding Javascript Functions to Header.php’ is closed to new replies.