我尝试在functons.php
后的enqueue scripts
</head>
文件中插入此HTML代码。要在您的网站上使用荧光笔,请在关闭之前添加以下HTML行您网站上每个应该找到“圣经参考”页面的<script id="bw-highlighter-config">
(function(w, d, s, e, id) {
w._bhparse = w._bhparse || [];
function l() {
if (d.getElementById(id)) return;
var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
x.parentNode.insertBefore(n, x);
}
(w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
})(window, document, 'script', 'load', 'bw-highlighter-src');
</script>
标记“
functions.php
这是/**
* Enqueue scripts and styles.
*/
function west_scripts() {
wp_enqueue_style( 'west-style', get_stylesheet_uri() );
if ( get_theme_mod('body_font_name') !='' ) {
wp_enqueue_style( 'west-body-fonts', '//fonts.googleapis.com/css?family=' . esc_attr(get_theme_mod('body_font_name')) );
} else {
wp_enqueue_style( 'west-body-fonts', '//fonts.googleapis.com/css?family=Roboto:400,400italic,500italic,500');
}
if ( get_theme_mod('headings_font_name') !='' ) {
wp_enqueue_style( 'west-headings-fonts', '//fonts.googleapis.com/css?family=' . esc_attr(get_theme_mod('headings_font_name')) );
} else {
wp_enqueue_style( 'west-headings-fonts', '//fonts.googleapis.com/css?family=Montserrat:400,700');
}
wp_enqueue_style( 'west-fontawesome', get_template_directory_uri() . '/fonts/font-awesome.min.css' );
wp_enqueue_script( 'west-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20130115', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( get_theme_mod('blog_layout') == 'masonry-layout' && (is_home() || is_archive()) ) {
wp_enqueue_script( 'west-masonry-init', get_template_directory_uri() . '/js/masonry-init.js', array('jquery-masonry'),'', true );
}
wp_enqueue_script( 'west-main', get_template_directory_uri() . '/js/main.js', array('jquery'), '', true );
wp_enqueue_script( 'west-scripts', get_template_directory_uri() . '/js/scripts.min.js', array('jquery'), '', true );
}
add_action( 'wp_enqueue_scripts', 'west_scripts' );
中我的排队部分的样子我在结束add_action函数之前尝试粘贴上面的HTML,但后来我留下了两个add_action函数并且我的网站没有正确加载?
asp.net mvc 4
答案 0 :(得分:1)
由于您使用的是Wordpress,因此需要在functions.php文件的末尾添加一些特殊代码,以告知Wordpress将您的HTML添加到</head>
标记上方:
add_action('wp_head','add_bw_highlighter');
function add_bw_highlighter() { ?>
<script id="bw-highlighter-config">
(function(w, d, s, e, id) {
w._bhparse = w._bhparse || [];
function l() {
if (d.getElementById(id)) return;
var n = d.createElement(s), x = d.getElementsByTagName(s)[0];
n.id = id; n.async = true; n.src = '//bibles.org/linker/js/client.js';
x.parentNode.insertBefore(n, x);
}
(w.attachEvent) ? w.attachEvent('on' + e, l) : w.addEventListener(e, l, false);
})(window, document, 'script', 'load', 'bw-highlighter-src');
</script>
<?php }