How to add functions php file in wodpress child theme

Add functions php file to wordpress child theme - pepfry.com

Add functions php file to wordpress child theme

How do you add functions php file in WodPress child theme?

Do you get error when you try to add functions php file which is copied from a parent theme into its child theme?

Its obvious that we don’t understand things at first place. Before understanding – we jump into doing things and suffer later. But, believe me – adding a functions.php file in a child theme isn’t that hectic as you think.

It’s very simple – If you have knowledge on PHP, then, you might figure out much faster than I did or most of you might do!

But, no worries – I’ll take you through the process and add functions php file into your child theme without causing an error. That’s my promise!!

Getting you started with the process:

Hope by this time you should have a WordPress website up and running with a Child theme in it. Other wise you wouldn’t have come here right?

Ok, Great!

Step1: First go into your parent theme and copy functions.php and paste it inside of your child theme.

Step2: Open the functions.php inside the child theme with a HTML editor. Preferably Notepad++ which is quite fast.

Step3: Delete all the contents inside the functions.php file except ‘<?php‘ at the top of the file and please, do not add the ‘?>’ at the end of the file that’s not needed.

According to WordPress you cannot just replicate a function that is already present in the parent functions.php file. Functions are referred only once. It can’t be everywhere.

That was the reason why I asked you to delete all the contents in there!

There was a setup function hanging on top of the parent functions.php file which is very important to run your functions. But, that’s not needed again here in the child theme.

Both child theme file and parent theme file will be parsed when WordPress process functions but, in an order. Child theme file is parsed first then the parent theme file. So the setup function will be referred from the parent theme.

Only inner function will be parsed from the child theme.

So, what next?

Now, you are good to add you new or custom functions to the functions.php file. Your functions.php file will look like this before you add any functions to it.

You can add any functions that are available on WordPress.org or write your own. I’ll take an example function and show you how to add it to the functions.php file in your child theme.

The above function adds a favicon link to the head of your website. And, when you add the above function to your Child theme’s functions.php file – It should look as shown below:

Make sure that you do not leave any white spaces before the <?php tag – that might lead to error.

That’s it guys – You just learn’t how to add functions php file and apply it with custom functions of your choice in your WordPress child theme!

Thanks for coming along with this tutorial – Any queries regarding this tutorial – do not hesitate to ask me.

Please, put all your questions in the comments section below and choose ‘Notify me of follow-up comments by email‘ – so that you are notified when I answer your question!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">