Creating Custom PHP Files

Hi,

I know there was a discussion about a similar Topic, but I couldn’t find that again. My question is more or less a general question. I want to add custom functionality to my theme and I’m not sure about the correct place to put it in. I’m thinking about either creating a plugin with all the functionality or (preferred way) putting everything inside the “inc” folder in my theme-structure.

So what I did is the following:

inside the custom.php file

require_once(__DIR__ . '/test.php');

That’s a very simplified example but just for understanding what exactly I want to do.
I want to have all my functionality inside the test.php and probably creating subfolders which get included inside the test.php

Almost the same as in that video here (fro about ~3:30), but with the difference that I want to keep the code in seperated files:

My Question:
What I’m not sure about (probably because I am too unexperienced with PG’s behaviour) is: Does the files get overwritten in any scenario? Do I have to take care, that they don’t get overwritten or are they safely stored in the inc folder?

I’m also fine with creating a Plugin, but I find it quite handy to have everything in one place! :wink:

TIA for your answer
Cheers

@Wolfgang.Hartl Hi, I am storing files & custom folders inside inc folder via custom.php and they have not got overwritten yet. But having a separate plugin might be a better idea than having fear of getting overwritten. I shifted the files to a custom plugin due to the same fear. But files didn’t got overwritten while using PG and there are backups too.

Hello! I have 10-12 WP sites with tons of custom code in inc/custom.php and it will never get overridden. These days it’s going to be automatically created for you when you start a new WP project but it will never get touched after that so you are safe to keep all code in there. Best!