• Hey,

    I am trying to figure out how to put a JS array and print it @ wp_head

    I am doing this

    function weather_process_header() {
    	echo "\n".'<!-- Start Of Script Generated By weather-plugin -->'."\n";
    		wp_register_style('weather-plugin-css', plugins_url('weather-plugin/weather.css'), false, '0.1', 'all');
    		wp_enqueue_script('ajaxcontent', '/wp-content/plugins/weather-plugin/js/ajax-dynamic-content.js', array('weatherplugin'), '2.1');
    		wp_enqueue_script('ajaxweather', '/wp-content/plugins/events-calendar/js/ajax-weather.js', array('weatherplugin'), '1.0b2');
    		wp_print_scripts(array('weather-plugin', 'weatherplugin'));
    		wp_print_styles(array('weather-plugin', 'weather-plugin-css'));
    	echo '<!-- End Of Script Generated By weather-plugin -->'."\n";
    }

    and then to the wp_head

    add_action('wp_head', 'weather_process_header');

    But it does not seem to work fine… It prints the CSS but not the JS array. Any help? ??

  • The topic ‘Add Javascript to WordPress header as an array’ is closed to new replies.