0

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

<script src="//code.jquery.com/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.com/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.

0

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:

  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.

-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 );

1
  • still,not working
    – Pranavmtn
    Mar 4 '20 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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