当前位置:网站首页>The first WordPress plug-in you are taught to make step by step
The first WordPress plug-in you are taught to make step by step
2022-06-28 16:38:00 【Hua Weiyun】
WordPress A plug-in in is a component that adds or extends functionality , You can enable or disable... As needed , And won't interfere with the core program / Software and its code .WordPress Designed to be lightweight and smooth , It is impossible to increase the flexibility of the basic code of the website . Then add custom features and functions to the plug-in , Allow users to design sites according to their specific requirements .
In this guide , Will learn how to develop the first WordPress plug-in unit .
precondition :
- WordPress install
- PHP Basic knowledge of
Steps of making plug-ins ——
1. go to WordPress install -> WordPress/wp-content/plugins

2. Create a new folder here and name it “ The plug-in name ”, In this case First-Plugin

3. Next , Create a new... In this folder PHP file , And give it the same name as the folder in this example First-Plugin.php

4. Now? , We add the name of the plug-in . Add... Contained in the file PHP The plug-in name in the comment .
PHP file First-Plugin.php Code for –
<?php/*** Plugin Name: First Plugin**/?>
5. Now? , go to WordPress Dashboard->Plugins, Here you can see our newly created plug-in and its name .

6. We should not leave the description blank , Because it can help users understand the purpose of plug-ins . So let's go through “Plugin Name:” Then add a new comment line to add the description of our plug-in , The title is “Description” And save it .PHP file First-Plugin.php Code for –
<?php/*** Plugin Name: First Plugin* Description: This is my first Plugin.**/?>
7. We have successfully added the description of our plug-in. Now go to Dashboard->plugin Look at it .

8. Next , We added some functionality to our first plug-in . We're going to add a name called first_plugin() The basic function of , It will print “HELLO This is my first Plugin”. And its short code allows it to be placed in WordPress Post or page .
Code -
<?php/*** Plugin Name: First Plugin* Description: This is my first Plugin.**/function First_Plugin(){ $content="HELLO This is my first Plugin."; return $content;}add_shortcode('myplugin', 'First_Plugin')?>
9. To display the output value of this function , We used WordPress Short code characteristics of . Go to post -> Create or edit a new post . Add the short code of the plug-in we just made there .
Abbreviated code - [myplugin]

10. To view plug-in output , Please browse the website and open our post of adding short code of plug-in .
This is what it looks like -

11. Now? , To use this plug-in function multiple times , We can use this short code many times . Just add a short code wherever we need this output .

12. Check the post for updated output , We get two identical sentences , Because we used short code twice in this post .

Now we have our plug-in , It returns a value , It can be used anywhere we want by using short codes .
边栏推荐
- tablestore中可以使用sql查询可以查出表中所有的数据吗?
- Zuckerberg to investors: don't expect anything from metauniverse
- Navicat 15 for MySQL
- Knowing these commands allows you to master shell's own tools
- GAIN的代码实现(4)——基于GAN的Spam数据集缺失数据填补(序)【改进版】
- 机器学习之卷积神经网络--CNN介绍
- 数字藏品热潮之下,你必须知道的那些事儿
- Tiktok actual battle ~ list of bloggers I follow, follow and check
- Steps to be taken for successful migration to the cloud
- [208] API design based on accesstoken
猜你喜欢

云上竞技,360°见证速度与激情

Azure Kinect微软摄像头Unity开发小结

A 24-year-old bald programmer teaches you how to continuously integrate and deliver microservice delivery. You can't learn how to cut me off
![[high concurrency foundation] hidden dangers and solutions of MySQL concurrency under different transaction isolation levels](/img/35/63c9793ec7bc1c90c759504e84dc96.png)
[high concurrency foundation] hidden dangers and solutions of MySQL concurrency under different transaction isolation levels

Super automation and the future of network security

leetcode:22. bracket-generating

知道这几个命令让你掌握Shell自带工具

Geoffrey Hinton: my 50 years of in-depth study and Research on mental skills

General solution of island problems and DFS framework

Etcd visualization tool: an introduction to kstone (I)
随机推荐
Lecturer solicitation order | Apache dolphin scheduler meetup sharing guests, looking forward to your topic and voice!
请问下大家有遇到过这种设置的主健和数据库一致的错误吗?
AI落地的新范式,就“藏”在下一场软件基础设施的重大升级里
机器学习之卷积神经网络使用cifar10数据集和alexnet网络模型训练分类模型,安装labelimg,以及报错ERROR
浅谈 SAP 软件里的价格折扣设计原理
Tiktok actual battle ~ list of bloggers I follow, follow and check
GCC efficient graph revolution for joint node representationlearning and clustering
Visual studio 2019 software installation package and installation tutorial
Focus on the 35 year old Kan: fear is because you don't have the ability to match your age
leetcode:22. 括号生成
Yesterday, metauniverse | Wal Mart set up an innovation department to explore metauniverse and Web3, and Dior released the metauniverse Exhibition
tablestore中可以使用sql查询可以查出表中所有的数据吗?
Solve the problem that subcomponents will not be destroyed through setTimeout
Knowing these commands allows you to master shell's own tools
【TcaplusDB知识库】TcaplusDB限制条件介绍
昨日元宇宙| 沃尔玛成立探索元宇宙和Web3的创新部门,Dior发布元宇宙展览
Change exchange (dynamic planning)
ID card copy tutorial (use t5577 card to copy 4100 card)
[high concurrency foundation] hidden dangers and solutions of MySQL concurrency under different transaction isolation levels
访中国信通院王蕴韬:数实融合赋能文化产业繁荣发展