Wordpress入队不起作用

Ian*_*Ian 2 javascript php wordpress

我有以下代码:

function register_scripts(){
    wp_register_style( 'new_style', plugins_url('/css/style.css', __FILE__));
    wp_register_script( 'google-maps-api', 'http://maps.google.com/maps/api/js?sensor=false' );
}

add_action('wp_enqueue_scripts', 'register_scripts'); 
Run Code Online (Sandbox Code Playgroud)

但它没有用,有谁能看到我做错了什么?

Obm*_*nen 5

喜欢评论 - 你已经注册了,但没有入队..

function regiqueue_scripts(){
    wp_register_style( 'new_style', plugins_url('/css/style.css', __FILE__));
    wp_register_script( 'google-maps-api', 'http://maps.google.com/maps/api/js?sensor=false' );
    wp_enqueue_style( 'new_style' ); // or use just enqueue without register .. but not the other way around 
    wp_enqueue_script( 'google-maps-api' ); 
}

add_action('wp_enqueue_scripts', 'regiqueue_scripts'); 
Run Code Online (Sandbox Code Playgroud)

你看 - 注册脚本只是让它们可以使用,但是在你告诉它之前它不会入队.功能wp_enqueue_xx()- 当所有参数填充CAN工作没有wp_register_xx()- 但不是相反.

始终使用两者,因为它允许更多地控制脚本的使用位置和时间.