Through plug-in: Code Snippets, the theme file will not be modified, and code can be easily added to functions
The best way to add custom PHP functions or filters to your website is through the code snippet plug-in.This has some advantages over using subtopics, because you can better organize the code you add.Enable and disable code snippets, export and import code, and more by clicking.There are even some good protection measures to prevent you from damaging your website. If you damage your website, there are some simple ways to revisit and repair your code.
You can download the code snippet plug-in by going to the WordPress management interface and clicking Plug in>Add New Plug in.
When enabled, you can navigate to code snippets in the Administration menu.After installation, Code Snippets provides some sample fragments that you can use to edit and understand its working principle.
If you want more information about the plug-in and its available settings, please check its WordPress plug-in page.
Code snippet example: change the logo link of your website. Take a quick example to build a code snippet. You can click Add New Code in the code snippet area, and then add your code to the code area.
You place this in the code area, and then add a short description below.Because this only affects the front end of the website, I chose "Only run on the front end of the website".
Save your changes and activate them, then you are set!