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 badges2 Answers
Reset to default -1I 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:
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/
If you are using a child theme, you need to call
get_stylesheet_directory_uri()
instead ofget_template_directory_uri()
. Parent theme assets are accessed usingtemplate
, and child theme assets are accessed usingstylesheet
.
本文标签: customizationwhy jquery is not loading in wordpress page
版权声明:本文标题:customization - why jquery is not loading in wordpress page? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744700299a2620524.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论