2
wordpress如何在没有自定义html的主题添加JS代码
source link: https://www.huhexian.com/28592.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
wordpress如何在没有自定义html的主题添加JS代码
2022-02-2410:42:12评论317字
今天我另一个商城需要添加全站自定义以及指定页面的JS代码,需要苹果封装,目的在于防止JS跳转,这里就把教程记录下,以免丢失。
来到主题目录下的 functions.php 里,将该代码添加即可
- function wpb_hook_javascript() {
- ?>
- // 你的代码
- <?php
- add_action('wp_head', 'wpb_hook_javascript');
或者添加指定的JS代码
- function wpb_hook_javascript() {
- if (is_single ('16')) {
- ?>
- // 你的JS代码
- <?php
- add_action('wp_head', 'wpb_hook_javascript');
测试代码,已经删掉。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK