Site logo

Archived topic

Does Short php snippet require Child Theme?

3 replies · Started by Michelle on November 3, 2020

Viewing posts 1–4 of 4

When I tried to upload a snippet of php into my php functions via Filezilla, I got an error message saying I need to have a child theme, but your documentation says "if all you’ll be doing is adding CSS or PHP, a child theme probably isn’t necessary."

I researched and found a review of GeneratePress that said "One of the best features of GeneratePress is that you no longer have to use a child theme. You can update your GeneratePress theme using the Elements module. It allows you to add custom code/PHP and hooks anywhere throughout your Wordpress site..."

I also read "the only time you risk losing changes is when you make them to the parent theme files or use the Additional CSS field" but other documentation says "In WordPress 4.7, WordPress added a core way to add CSS to your site inside the Customizer which you can find in Customize > Additional CSS."

I am so confused. Do I need a child theme? I did not understand answers given to others on this forum that asked the same question.

Hi,

I researched and found a review of GeneratePress that said “One of the best features of GeneratePress is that you no longer have to use a child theme. You can update your GeneratePress theme using the Elements module. It allows you to add custom code/PHP and hooks anywhere throughout your WordPress site…”

The author probably pertained to the Hook Element. And yes you can add your PHP snippets there.

More on Hook Element here - https://docs.generatepress.com/article/hooks-element-overview/

I am so confused. Do I need a child theme? I did not understand answers given to others on this forum that asked the same question.

If you find creating a child theme a daunting task, you can use the Hook Element.

Alternatively, you can install a Code Snippet plugin to add your PHP snippets.

https://docs.generatepress.com/article/adding-php/#code-snippets

To answer your question directly: No, child themes are NOT necessary for you to be able PHP snippets. :)

Thank you for clarifying. I added a child theme, and am now removing it to use the hook element feature instead.

Thank you for clarifying. I added a child theme, and am now removing it to use the hook element feature instead.

No problem. :)

This archived topic is closed to new replies.