Php jQuery don';t在Wordpress中加载子主题
我想在我的子主题中添加一个HTML代码,以便在Wordpress的子主题中添加一个图标。目前,情况是这样的: 我想添加一个这样的Youtube图标(这不在主题中,这就是为什么我想添加HTML): 因此,我使用以下代码设置function.php代码:Php jQuery don';t在Wordpress中加载子主题,php,jquery,html,wordpress,Php,Jquery,Html,Wordpress,我想在我的子主题中添加一个HTML代码,以便在Wordpress的子主题中添加一个图标。目前,情况是这样的: 我想添加一个这样的Youtube图标(这不在主题中,这就是为什么我想添加HTML): 因此,我使用以下代码设置function.php代码: <?php function mytheme_scripts() { wp_enqueue_script('mytheme_functions', get_stylesheet_directory_uri().'/js/mySc
<?php
function mytheme_scripts() {
wp_enqueue_script('mytheme_functions', get_stylesheet_directory_uri().'/js/myScript.js', array('jquery'), '', true);
wp_enqueue_script('jq_ui', get_stylesheet_directory_uri().'/js/jquery-ui-1.10.3.custom.min.js', array('jquery')); //Not sure if we can use the CDN here instead of a local version.
}
add_action( 'wp_enqueue_scripts', 'mytheme_scripts' );
?>
以下是我的jQuery代码:
$(document).ready(function($) {
$(".social-google-plus").append('<li class="social-youtube"><a href="http://www.twitter.com/TWorldAngels" target="blank"><i class="fa fa-youtube"></i></a></li>');
});
$(文档).ready(函数($){
$(“.social google plus”).append(“”);
});
我的jQuery代码位于我的子主题中的/js文件夹中。但它不起作用。怎么了?谢谢大家 我很确定我的装载正确 可能是$产生了问题(WordPress如何防止js库之间的冲突) 请尝试以下操作:
jQuery(document).ready(function($) {
$(".social-google-plus").append('<li class="social-youtube"><a href="http://www.twitter.com/TWorldAngels" target="blank"><i class="fa fa-youtube"></i></a></li>');
});
jQuery(document).ready(函数($){
$(“.social google plus”).append(“”);
});
(我还没有测试你的代码)
如果这无法解决问题,您能否提供进一步的详细信息?控制台错误?-1-检查Chrome开发者工具中的“脚本”选项卡:jQuery应该从“wp includes”加载-2-如果您的子主题模板中有一个“js/functions.js”,默认情况下不会加载它。将下一个脚本标记添加到孩子的header.php: