add call to js file in child functions.php
-
I have created a copy of the theme shipyard into a theme I call curling55 and have now created a child theme of curling55 as well, I want to make any further theme changes in the child theme.
I want to call in the js file respond.src.js to handle media queries in IE8, but this must be called after the style sheet is loaded. The code in the parent theme is:
// Enqueues scripts and styles for front-end
function curling55_scripts() {
if (!is_admin()) {
wp_enqueue_style( ‘style’, get_stylesheet_uri() );
wp_enqueue_script( ‘nav’, get_template_directory_uri() . ‘/js/nav.js’, array( ‘jquery’ ) );
}
if ( is_singular() && comments_open() && get_option( ‘thread_comments’ ) )
wp_enqueue_script( ‘comment-reply’ );
}
add_action( ‘wp_enqueue_scripts’, ‘curling55_scripts’ );If I code up functions.php in the child theme like this:
<?php
/***
* Add call to respond.src.js so IE8 can process media queries
* (must follow call to style.css)
*
*/
// Enqueue scripts and styles
function curling55child_scripts() {
wp_enqueue_script( ‘respond’, get_stylesheet_directory_uri() . ‘/js/respond.src.js’, array( ‘jquery’ ) );
}
add_action( ‘wp_enqueue_scripts’, ‘curling55child_scripts’, 20 );
?>I get this error:
Warning: Cannot modify header information – headers already sent by (output started at /home/content/s/u/n/sunflowerbaker/html/wp/wp-content/themes/curling55-child/functions.php:12) in /home/content/s/u/n/sunflowerbaker/html/wp/wp-includes/pluggable.php on line 896
How do I code the functions.php in the child theme to do this and not give me an error?
Al
- The topic ‘add call to js file in child functions.php’ is closed to new replies.