Add php function

Posted in: Newspaper
Post count: 28

Hi
I’m looking for a way to add some php functions in the header, but i prefer not to do it by copy the header file to the child theme in order not to touch the code.

What is the best way?

I know there is a js and css to embed in the Theme Panel, but what about php?

Thanks

Post count: 22421

Hello,

Unfortunately there is no PHP box you can add code to. You can only edit the core files directly or with a child theme. The child theme is the safest way as you do not modify the file directly. But even if you do not use a child theme and modify the main file, you can always keep a back-up of these files if something goes wrong and simply copy them over the modified ones. (just be careful when updating the theme, look out for files that get modified in the changelog so you can adjust the modifications in the updated files as well)

I hope this helps.
Thank you!

Post count: 28

Yea, i’m working with child theme. So just copy the header.php to the child folder?

Post count: 22421

Hi,

You have to recreate the path of the file in your child theme. In this case it’s newspaper/header.php
We have a child theme tutorial in our documentation if you would like to read more on the subject: https://forum.tagdiv.com/the-child-theme-support-tutorial/

Thank you!

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newspaper’ is closed to new topics and replies.