Where do I add my custom PHP code?

Inside the child theme #

The best way to add your custom PHP code (small snippets) is in the functions.php file of your child theme: wp-content/themes/xstore-child/functions.php

The functions file behaves like a WordPress Plugin, adding features and functionality to a WordPress site through PHP code. You can use it to call native PHP functions, WordPress functions, or to define your own functions.

Note: It is strongly advised to refrain from inserting PHP code in the functions.php file of the parent theme under any circumstances. To ensure that your customizations persist during theme updates, it is always recommended to utilize the functions.php file of your child theme.

By plugin #

Alternatively, simply use a “functionality” plugin such as the Code Snippets plugin to manage your custom PHP snippets.

Updated on September 27, 2024
Was this Article helpful?