Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I started to use contact 7 plugin and I'm having a slider and some effects on other images when i activate the plugin they stop working this is the web page

http://www.digitalways.com.sa/ 

I don't understand what it do! if it stops the javascript or css files but I searched in the files if it has the same names and stopping them from working but it have different names

i tried to add this code to function.php so i could add jQuery by the right way but it gave me server error

jQuery(document).ready(function(){
function my_init() {
if (!is_admin()) {
    // comment out the next two lines to load the local copy of jQuery
    wp_deregister_script('jquery'); 
    wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', false, '1.3.2'); 
    wp_enqueue_script('jquery');
}
 }
  add_action('init', 'my_init');
  });
share|improve this question
add comment

4 Answers

It's not the Plugin that is at fault, but the Theme.

The Theme enqueues a custom version of jQuery, which you should never ever do. Also when the jQuery plugin is initialized, you need to use noConflict wrappers like this:

jQuery(document).ready(function($) {
    // Inside of this function, $() will work as an alias for jQuery()
    // and other libraries also using $ will not be accessible under this shortcut
});

I assume that Contact Form 7 uses jQuery as well, but since the Theme does it wrong, this causes a conflict.

share|improve this answer
    
Fränk thanks for reply but what do you mean by custom version is there a way to add jquery without adding the version can you please explain more –  sarah Apr 24 '13 at 8:33
    
jQuery is shipped with WordPress Core. If you want to use jQuery in your Theme, all you need to do is to add wp_enqueue_script( 'jquery' ); in your functions.php. Please keep in mind that all scripts in a Theme need to be correctly enqueued via a custom function in functions.php: codex.wordpress.org/Function_Reference/wp_enqueue_script –  Fränk Apr 24 '13 at 8:42
    
thanks Fränk but i want to ask one more question when i add the code to function.php should i add something else in the header part to use this function –  sarah Apr 24 '13 at 8:55
    
There is no additional code in header.php needed. Your header.php file should only contain HTML in most cases. The way it works with WordPress is that you write your own PHP functions in the Theme's functions.php file, and you hook this function to an action. WordPress will then take care of putting the code in the correct place (i.e. enqueuing Javascript in the head of the HTML document). –  Fränk Apr 24 '13 at 9:00
    
i tried some codesand they gave me server error thats why i was adding it to the header i cant find the correct way –  sarah Apr 24 '13 at 9:37
show 1 more comment

ok i added this code to function.php it didn't give me " server error " but i think there still something missing because jquery still not working

 add_action( 'wp_enqueue_scripts', 'wpcandy_load_javascript_files' );
 wp_register_script( 'jquery', get_template_directory_uri() . '/javascript/jquery-1.8.2.min.js', array('jquery'), '1.8.2', true );

wp_register_script( 'jquery-defaultvalue.js', get_template_directory_uri() . '/javascript/jquery-defaultvalue.js', array('jquery-defaultvalue.js'), '1.0', true );

wp_register_script( 'tytabs.jquery', get_template_directory_uri().'/javascript/tytabs.jquery.min.js', array('jquery'), '1.0', true );

wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-defaultvalue.js' );
wp_enqueue_script( 'tytabs.jquery' );

if ( is_front_page() ) {
wp_enqueue_script('jquery');
 wp_enqueue_script( 'jquery-defaultvalue.js' );
wp_enqueue_script( 'tytabs.jquery' );

}

}
share|improve this answer
add comment

Try this:

function my_theme_prefix_load_javascript() {

    wp_register_script( 'jquery-defaultvalue.js', get_template_directory_uri() . '/javascript/jquery-defaultvalue.js', array('jquery'), '1.0', true );
    wp_register_script( 'tytabs.jquery', get_template_directory_uri().'/javascript/tytabs.jquery.min.js', array('jquery'), '1.0', true );

    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'jquery-defaultvalue.js' );
    wp_enqueue_script( 'tytabs.jquery' )

}
add_action( 'wp_enqueue_scripts', 'my_theme_prefix_load_javascript' );
share|improve this answer
    
there is something wrpng in that code when i add it to function.php it gives me an error –  sarah Apr 24 '13 at 11:40
    
Could you post the error message that is displayed? –  Fränk Apr 24 '13 at 20:23
    
it is the braces before the add action '{'and i also tried to ignore the error and run the code but it not working –  sarah Apr 25 '13 at 4:51
    
hi frank thanks for all your support i really appreciated that i think may be the problem because of the coflict of some script in header and footer like this one <script type="text/javascript"> <!-- $(document).ready(function(){ $("#tabsholder").tytabs({ tabinit:"1", fadespeed:"fast" }); $("#tabsholder2").tytabs({ prefixtabs:"tabz", prefixcontent:"contentz", classcontent:"tabscontent", tabinit:"3", catchget:"tab1", fadespeed:"normal" }); }); --> </script> –  sarah Apr 25 '13 at 5:16
    
So is it working now? –  Fränk Apr 25 '13 at 12:20
show 1 more comment
up vote 0 down vote accepted

i found the solution i just added all scripts together

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.