如何将自定义JavaScript添加到您的WordPress网站?

news/2024/5/12 23:42:42/文章来源:https://blog.csdn.net/culing2941/article/details/108616968

When you want to change the theme of your site, one thing that needs to be done is to add custom JavaScript to it. However, there are other options available if you do not want to add it to your site. For instance, simply add the ‘Heat and Footer Script’ as an option which is much less intrusive compared to the other.

当您想要更改网站的主题时,需要做的一件事是向其添加自定义JavaScript。 但是,如果您不想将其添加到站点,则还有其他选项可用。 例如,只需添加“ Heat and Footer Script”作为选项,与其他选项相比,其侵入性要小得多。

Well, this article is not about the various alternatives, but mainly about the JavaScript which can be added to your WordPress site. How you can exactly do the task? We will share the details with you in the section below.

好吧,本文不是关于各种替代方案,而是主要关于可以添加到WordPress网站JavaScript。 您如何才能准确地完成任务? 我们将在下面的部分中与您分享详细信息。

将JavaScript添加到WordPress网站的选项 (Options to add JavaScript to WordPress Site)

How to Add Custom JavaScript into Your WordPress Site

Image Source

图片来源

It is not difficult to add custom JavaScript to a WordPress site. All you need to know the way through which it can be done. Two main options and ways in which you can add JavaScript to WordPress sites include the following:

将自定义JavaScript添加到WordPress网站并不难。 您需要知道的所有方法。 可以将JavaScript添加到WordPress网站的两个主要选项和方法如下:

1.添加自定义JavaScript文件 (1. Add Custom JavaScript File)

First of all, you have to save the file with .js format. After this, you may add this into the folder http://wp-content/themes/your-theme/js/. When you do this, go to the settings where there will be two options in front of you. Either you can add it to the header, or the footer. This is how simple it can be.

首先,您必须以.js格式保存文件。 之后,您可以将其添加到文件夹http:// wp-content / themes / your-theme / js /中 。 执行此操作时,请转到设置,其中前面有两个选项。 您可以将其添加到页眉或页脚。 这是多么简单。

2.添加不带文件的自定义JavaScript (2. Add Custom JavaScript Without File)

This option is simple to add the custom JavaScript without file. You do not need to save this file as .js format. Rather, you can directly upload it to the folder http://wp-content/themes/your-theme/js/. The header will be the place where you will add it and then go to the save setting when you complete the process.

此选项很容易添加不带文件的自定义JavaScript。 您无需将此文件另存为.js格式。 相反,您可以将其直接上传到文件夹http:// wp-content / themes / your-theme / js / 。 标头将是您添加标头的位置,然后在完成该过程后转到保存设置。

你不应该做的一件事 (One Thing You Should Never Do)

Although it is quite clear that a much better option to add the custom JavaScript to your WordPress site is to use the ‘SCRIPT’ tag. This is added directly into either header or footer.php. However, you should never do that. As WordPress has a specific loading sequence, therefore, this sequence needs to be respected, and this option must not be availed.

虽然很明显,将自定义JavaScript添加到WordPress网站的更好选择是使用'SCRIPT'标签。 将其直接添加到header或footer.php中。 但是,您绝对不要这样做。 由于WordPress具有特定的加载顺序,因此,必须遵守此顺序,并且不得使用此选项。

The reason behind this is that if you will add to the header or footer.php which will lead to changes within the whole theme. The core and plugins of WordPress might also face conflicts due to the addition of custom JavaScript in this way. Instead of this option that brings so many issues in your WordPress site, therefore, try to use only the above-mentioned two options. Make sure that you do not add it to the header or footer, even if it seems the only option.

这背后的原因是,如果您将添加到header或footer.php中,这将导致整个主题内的更改。 由于以这种方式添加了自定义JavaScript,WordPress的核心和插件也可能会面临冲突。 因此,请尝试仅使用上述两个选项,而不是在WordPress网站中带来很多问题的此选项。 确保不要将其添加到页眉或页脚,即使它似乎是唯一的选择。

When it comes to importing templates, getting a reliable WordPress website builder will allow you to import templates for just about any topic or any niche with endless customization options.

当涉及到导入模板时,获得可靠的WordPress网站构建器将使您可以使用无穷的自定义选项为几乎任何主题或任何细分市场导入模板。

结论 (Conclusion)

As you can see that the custom JavaScript is not difficult to add to the WordPress site. It will take a few minutes if you know how to do it. We have explained the information in detail where you will get to know about each point. Follow the step by step, and do not make amendments on your own.

如您所见,自定义JavaScript添加到WordPress网站并不困难。 如果您知道该怎么做,将需要几分钟。 我们已经详细解释了信息,您将在其中了解每个点。 请循序渐进,不要自己修改。

翻译自: https://www.thecrazyprogrammer.com/2020/06/how-to-add-custom-javascript-into-your-wordpress-site.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_734748.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

创建类的三个步骤_如何通过5个简单的步骤创建企业网站

创建类的三个步骤Having the right business website can help any business alter their fortunes. If you are a small or big business owner, CEO, or entrepreneur, looking to grow your business, then it is important that you focus on your website. 拥有合适的企业…

网页和网站之间的区别

The difference between webpage and website is unanimously erred in terms of their functionalities, and often when anyone reads these two terms starting with “Web.” 网页和网站之间的区别在功能上是一致的,而且通常是当有人阅读以“ Web”开头的这两个…

ue4 加快移动_加快移动网站的9种方法

ue4 加快移动Website speed refers to how fast a site responds to requests from the Web. As I am about to highlight in this article, the speed with which a website load is very critical to both the users and owners. 网站速度是指网站响应Web请求的速度。 正如我…

有时候有些服务类的网站就是不走心啊

http://www.gb688.cn/BzptWeb/appmanager/eip/main?_nfpbtrue&_pageLabelportal_main_portal_page_4#wlp_portal_main_portal_page_4 请看: 文章来源:刘俊涛的博客 欢迎关注,有问题一起学习欢迎留言、评论转载于:https://www.cnblogs.co…

基于django的个人博客网站建立(七)

基于django的个人博客网站建立&#xff08;七&#xff09; 前言 网站效果可点击这里访问 这次在原来的基础上添加或修改一些小功能 具体内容 1.代码高亮 在原来的blog-details.html页面添加下面的代码&#xff1a; <link href"http://cdn.bootcss.com/highlight.js/9.1…

优酷网站服务器的带宽是多少,云服务器1M的带宽到底多大?90%的网站够用了

1M&#xff0c;作为云服务器最低的带宽配置&#xff0c;到底能承受多大的流量&#xff1f;在选配云服务器带宽的时候&#xff0c;看到带宽大小的时候&#xff0c;头疼病总是发作&#xff0c;带宽买小了&#xff0c;网站太卡&#xff0c;用户体验不好影响业务&#xff0c;带宽买…

使用码云或GitHub搭建简单的个人网站(补充hexo搭建博客)

视频链接&#xff1a;https://www.bilibili.com/video/av64294697 使用码云或GitHub搭建个人网站码云&#xff1a; 1、新建一个仓库 路径名会影响你的个人网站的网址&#xff08;自行修改&#xff09;&#xff0c;开源&#xff08;公开&#xff09;&#xff0c;其他默认…

bootstrap 分页_学习写个网站(5)Bootstrap学习2

吃了2天烧烤夜宵&#xff0c;还是得讲点自律。【正文】继续bootstrap&#xff0c;还是菜鸟教程。11. 分页就是还有种就是翻页&#xff0c;12. 标签class"label label-default">默认标签</span>label-primarylabel-success13. 警告就是那种可以取消的消息&am…

个人主页html代码_羡慕别人有自己的网站吗?这里有搭建免费个人主页的傻瓜式教程!...

想拥有一个免费的个人主页吗&#xff1f;在这里&#xff0c;你可以发布自己的博客、自由定制网站的主题&#xff0c;你可以拥有极好的创作体验&#xff0c;它可以成为你对外的一张“名片”&#xff0c;体现你的品味和兴趣&#xff0c;还有更重要的&#xff0c;它是免费的、可控…

springboot获取不到请求头_基于springBoot的国际化网站处理

为了在不同得语言环境下使用不同的语言提示&#xff0c;所以一般会在网站引入网站国际化处理。下面讲解一下springboot对这国际化的支持1.springboot进行国际化处理的类public class MessageSourceAutoConfiguration {Beanpublic MessageSource messageSource(MessageSourcePro…

大型游戏网站源码_自学Python才两天,就成功编写俄罗斯方块游戏,这难道不是天才?...

人们常说&#xff0c;python不适合做游戏&#xff0c;但我偏爱玩游戏&#xff0c;做不了大的&#xff0c;做个小的也行啊。于是&#xff0c;我在自己毫无基础的条件下&#xff0c;用两天时间学python基础理论&#xff0c;再用已有的俄罗斯方块游戏源码和源文件&#xff0c;在我…

如何使用Zend Framework、Smarty、Ajax创建一流的网站

如何使用Zend Framework、Smarty、Ajax创建一流的网站“读完本书后&#xff0c;我发现自己对Web开发和MVC模式的理解都已经今非昔比……强烈推荐此书&#xff01;”——Amazon.com“……一部极富启发性的PHP实战指导书&#xff0c;业界专家充分演示了如何使用Zend Framework、S…

seo查询工具源码_网站SEO必备的10款辅助工具

1、百度站长平台(免费)百度站长平台是全球最大的中文网站管理员官方平台。提供SEO优化建议、站长工具、权威数据算法公布。2、百度推广(免费、关键词挖掘)百度推广是百度国内首创的一种按效果付费的网络推广方式&#xff0c;重点是工具里面有关键词挖掘工具&#xff0c;竞价人员…

围观:8个网站被黑,又一次免费的安全检查,‘网络安全’问题多多,让人担忧啊。...

据相关人士爆料&#xff0c;2009年11月7日下午2点左右一下网站被安全检查。图一、成都大学官网 http://www.cdu.edu.cn/404.html图二、大学生招聘网 http://bbs.hiall.com.cn/404.html 图三、中国旅游网 http://cdms.yahtour.com/404.html图四、IDC …

fluke ti32英文使用说明_烟台高端英文网站制作-鸿强传媒

网站优化公司,很多做网站优化的企业都遇到了这样的一个问题,那就是企业网站的流量很少以及在搜索引擎上的排名也比较靠后,而网站跳出率反而越来越高.网站关键词网站优化公司告诉你们这是因为网站的打开速度很慢造成的,要知道网站打开速度不理想的话,对于企业网站的网站优化是有…

开源软件网站

为什么80%的码农都做不了架构师&#xff1f;>>> SourceForge.net 以下是编程技术相关网站 http://special.e800.com.cn/080504/ 深入解析Java网络编程 http://www.linuxpk.com/type216_1.html Linux-网络编程 http://violasogni.javaeye.com/blog/548694 …

Mysql+Nginx+Apache2+PHP网站环境搭建(编译安装)

1.Centos编译环境搭建&#xff1a;yum -y install yum-fastestmirror使用fastestmirror插件给yum加速 yum check-update安装一些必要的软件&#xff1a; yum -y install gcc gcc-c screen autoconf automake libjpeg libjpeg-devel libpng libpng-devel freetype freetype-dev…

ubuntu系统服务器查看在运行,ubuntu如何查看系统版本信息_网站服务器运行维护...

linux不支持中文怎么办_网站服务器运行维护linux不支持中文的解决办法&#xff1a;首先安装中文语言包&#xff1b;然后编辑“/etc/profile”配置文件&#xff0c;并添加“export LANG"zh_CN.UTF-8"”&#xff1b;最后通过命令“# . /etc/profile”重新载入即可。一、…

BSU网站加速技术

BSU网站加速技术 BSU&#xff08;BrowserSpeedUp&#xff09;网站加速技术&#xff0c;是博看文思针对当前国内传统网站制作的弊端&#xff0c;从前端开发角度出发&#xff0c;提出的一门提高网页打开速度的技术。通过大量实例证明&#xff1a;使用BSU网站加速技术制作的网站比…

网站添加“分享按钮”

站长基本上都会给自己网站添加“分享按钮” 1、http://www.bshare.cn/ 和 2、http://www.jiathis.com/ 3、百度分享&#xff1a;&#xff08;推荐&#xff09; http://share.baidu.com/ 注意它的第二条&#xff1a; 使用了百度分享的网页可以更快地被百度爬虫发现&#xff0c;从…