I've successfully linked jQuery to WordPress within the functions.php
. However, it appears that the center.js
is not loading. I say this, because the console is giving me this error: Uncaught TypeError: Object [object Object] has no method 'center'
I am calling all scripts with <?php wp_head(); ?>
<?php wp_head(); ?>
within the header.php
. Here is my functions.php
:
<?php
function add_google_jquery() {
if ( !is_admin() ) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"), false);
wp_enqueue_script('jquery');
}
}
add_action('wp_print_scripts ', 'add_google_jquery');
// just added jQuery
function add_google_center() {
if ( !is_admin() ) {
wp_register_script('center', ("http://jquerydevbrazil.googlecode.com/svn/trunk/jquery.center.js"), false);
wp_enqueue_script('center');
}
}
add_action('wp_print_scripts_center ', 'add_google_center');
set_post_thumbnail_size( 800, 600, 1 );
function PA_stylesheet() {
wp_enqueue_style( 'pa-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'PA_stylesheet' );
function PA_javascript() {
wp_enqueue_script( 'custom-script',
get_stylesheet_directory_uri() . '/tran.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'PA_javascript' );
?>
Would anyone be able to help solve this problem?
You shouldn't be using wp_print_scripts. Use wp_enqueue_scripts instead.
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_print_scripts
(this is for tying in your add_google_jquery and add_google_center functions)
So, all you need to do is replace 'wp_print_scripts' with 'wp_enqueue_scripts' and you should be good to go
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.