# Creating Custom PHP Files

**URL:** <https://forum.pinegrow.com/t/creating-custom-php-files/6967>\
**Category:** WordPress\
**Created:** [September 18, 2022, 11:00am UTC](https://forum.pinegrow.com/t/creating-custom-php-files/6967 "2022-09-18T11:00:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wolfgang.Hartl](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/wolfgang.hartl/32/4621_2.png) [@Wolfgang.Hartl](https://forum.pinegrow.com/u/Wolfgang.Hartl)\
**Post date:** [September 18, 2022, 11:00am UTC](https://forum.pinegrow.com/t/creating-custom-php-files/6967/1 "2022-09-18T11:00:38Z")

</div>

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

```auto
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:

> **[Adding custom PHP code | Pinegrow Web Editor](https://pinegrow.com/docs/woocommerce/creating-custom-woocommerce-themes-course/adding-custom-php-code/)**
>
> How to extend the project with custom features that are not supported by Pinegrow?

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! 😉

TIA for your answer  
Cheers

---

<div class="post-metadata">

**Author:** ![Pinegrow\_Learner](https://avatars.discourse-cdn.com/v4/letter/p/df705f/32.png) [@Pinegrow\_Learner](https://forum.pinegrow.com/u/Pinegrow_Learner)\
**Post date:** [September 19, 2022, 11:47am UTC](https://forum.pinegrow.com/t/creating-custom-php-files/6967/2 "2022-09-19T11:47:58Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![jonroc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/jonroc/32/2805_2.png) [@jonroc](https://forum.pinegrow.com/u/jonroc)\
**Post date:** [October 5, 2022, 7:18pm UTC](https://forum.pinegrow.com/t/creating-custom-php-files/6967/3 "2022-10-05T19:18:01Z")

</div>

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!
