- This topic has 5 replies, 2 voices, and was last updated 11 months, 1 week ago by Leo.
October 17, 2019 at 9:26 am #1037380sofia
I am upgrading my website theme to GeneratePress and trying to move all my existing snippets and tracking codes over (currently working on a staging copy). I have a piece of code to add to the functions.php file but when I go to the theme editor it’s saying “Please do not make any edits to this file. All edits should be done in a child theme.”
But I don’t have any child theme. I’m using the Generatepress theme and the Pro plugin and just customizing things from scratch. In the Themes, the only theme that’s active is Generatepress.
The code I want to add relates to a social share plugin, to force Pinterest hidden images to be excluded from lazy loading. the code is included in my old theme so I am not sure why I can’t place it in the functions.php of the new theme. Is there another location?
Also, I’d prefer not to have to use a plugin to add this code.
Thank you so much!October 17, 2019 at 9:43 am #1037387LeoStaffCustomer Support
It’s never a good idea to add modify the theme core files like
functions.phpas they will be erased during updates.
Try using one of the methods here instead:
I’d say Code Snippets is the easiest solution and we use it all the time.
If not the next best option is the child theme’s
Let me know if this helps 🙂October 17, 2019 at 9:52 am #1037401sofia
Thank you for your quick response.
As I said before I am not using a Child theme, so I was confused when I read I can only add it to the child theme. Do you mean one of those site library themes? because I’m not using any of those.
I looked at that article before… So if I add that plugin, can I delete it after the code is added?
The reason I am changing my theme is to help speed up my website which has been extremely slow on my last theme and part of that was also removing unnecessary plugins… that’s why I asked 🙂
Thank youOctober 17, 2019 at 9:55 am #1037407LeoStaffCustomer Support
It would be a blank child theme:
No you cannot remove the plugin and keep the code activated. The plugin should have very minimal impact to your site speed.
You can run your site through speed test before and after.October 17, 2019 at 9:57 am #1037412sofia
Ohh I see! thank you so much. I’m gonna check out the articles now and try the plugin also.
SofiaOctober 17, 2019 at 9:58 am #1037414
- You must be logged in to reply to this topic.