admin管理员组

文章数量:1389768

I want to add jquery plugin to wordpress webpage to provide some animations. I have downloaded "jquery.plate.js" from jqueryscript and saved it locally in my custom themes,(js/jquery.plate.js) js folder.

<script src="//code.jquery/jquery-3.2.1.slim.min.js"></script>

<script src="jquery.plate.js"></script>
  • I have added the above code in my header using "echo get_template_directory_uri();" function.

not working!

  • tried with adding following code in function.php:

    function my_extrajs() { ?>
      <script src="//code.jquery/jquery-3.2.1.slim.min.js"></script>
      <script type="text/javascript" src="<?php echo 
      get_template_directory_uri(); ?>/js/jquery.plate.js"></script>
      <?php }
    
    add_action('wp_head', 'my_extrajs');
    

Still not working!

  • Tried with adding another code in functions.php:

    function theme_name_scripts() {
      wp_enqueue_style( 'style-name', get_stylesheet_uri() );
      wp_enqueue_script( 'jquery.plate.js', get_template_directory_uri() . '/js/jquery.plate.js', array('jquery'), '1.0.0', true );}
    add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
    

not working!!

    $('.text-white.follow').plate();

this code is i used to retrieve jquery animation.for the following element:

      <div class="col-md-1 col-2 social">
                        <span class="text-white follow"><label>FOLLOW</label></span>
                        <span><a href=""><img src="<?php echo get_template_directory_uri(); ?>/images/social1.png"></a></span>
                        <span><a href=""><img src="<?php echo get_template_directory_uri(); ?>/images/social2.png"></a></span>
                        <span><a href=""><img src="<?php echo get_template_directory_uri(); ?>/images/social3.png"></a></span>
                    </div>

Any idea, where i missed??

Also,i am beginner in wordpress.Any help would be appreciable.

I want to add jquery plugin to wordpress webpage to provide some animations. I have downloaded "jquery.plate.js" from jqueryscript and saved it locally in my custom themes,(js/jquery.plate.js) js folder.

<script src="//code.jquery/jquery-3.2.1.slim.min.js"></script>

<script src="jquery.plate.js"></script>
  • I have added the above code in my header using "echo get_template_directory_uri();" function.

not working!

  • tried with adding following code in function.php:

    function my_extrajs() { ?>
      <script src="//code.jquery/jquery-3.2.1.slim.min.js"></script>
      <script type="text/javascript" src="<?php echo 
      get_template_directory_uri(); ?>/js/jquery.plate.js"></script>
      <?php }
    
    add_action('wp_head', 'my_extrajs');
    

Still not working!

  • Tried with adding another code in functions.php:

    function theme_name_scripts() {
      wp_enqueue_style( 'style-name', get_stylesheet_uri() );
      wp_enqueue_script( 'jquery.plate.js', get_template_directory_uri() . '/js/jquery.plate.js', array('jquery'), '1.0.0', true );}
    add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
    

not working!!

    $('.text-white.follow').plate();

this code is i used to retrieve jquery animation.for the following element:

      <div class="col-md-1 col-2 social">
                        <span class="text-white follow"><label>FOLLOW</label></span>
                        <span><a href=""><img src="<?php echo get_template_directory_uri(); ?>/images/social1.png"></a></span>
                        <span><a href=""><img src="<?php echo get_template_directory_uri(); ?>/images/social2.png"></a></span>
                        <span><a href=""><img src="<?php echo get_template_directory_uri(); ?>/images/social3.png"></a></span>
                    </div>

Any idea, where i missed??

Also,i am beginner in wordpress.Any help would be appreciable.

Share Improve this question asked Mar 3, 2020 at 7:30 PranavmtnPranavmtn 13 bronze badges
Add a comment  | 

2 Answers 2

Reset to default -1

I think , you did mistake here

wp_enqueue_script( 'jquery.plate.js', get_template_directory_uri() . '/js/jquery.plate.js', array('jquery'), '1.0.0', true );

try below line

wp_enqueue_script( 'jquery-plate-js', get_template_directory_uri() . '/js/jquery.plate.js', array('jquery'), '1.0.0', true );

There are two things you should try:

  1. Wordpress loads jQuery in compatibility mode, so you will need to use the noconflict syntax, ex. jQuery('.text-white.follow').plate();. More information:

    • https://learn.jquery/using-jquery-core/avoid-conflicts-other-libraries/
    • https://digwp/2011/09/using-instead-of-jquery-in-wordpress/
  2. If you are using a child theme, you need to call get_stylesheet_directory_uri() instead of get_template_directory_uri(). Parent theme assets are accessed using template, and child theme assets are accessed using stylesheet.

本文标签: customizationwhy jquery is not loading in wordpress page