I made a few changes to helpers_blog.php file inside the inc directory of your theme, Now when I transfer this file to gillion-child > inc folder, the site doesn’t work. It gives an error are shown in the attached screenshot.
Please refer both the screenshots and let me know how can I modify the theme with a child theme
I get this error message when I enable the debug
Fatal error: Cannot redeclare gillion_tag_widget_limit() (previously declared in /www/techtantra_726/public/wp-content/themes/gillion-child/inc/helpers_blog.php:824) in /www/techtantra_726/public/wp-content/themes/gillion/inc/helpers_blog.php on line 824
I hope you are well today and thank you for your question.
This is happening because you are redeclaring the function gillion_tag_widget_limit in the child theme which is already declared in the Gillion theme.
You have to modify this function using the filter which is used in the Gillion theme as below.
If you are not a developer or don’t know about the WordPress hooks then you can consider hiring a developer to develop it for you. You can hire a developer from any freelance site. Shufflehound recommends the developer https://www.upwork.com/freelancers/~011652ffec8865c6d5
Thank you for your reply.
I haven’t redeclared the function, it’s already in your file and I don’t want to customize that function, I am want to modify the other code.
And as per the WordPress child theme documentation, if we copy the parent theme file to Child theme folder then it will use the Child Theme’s file. I am quoting text from their documentation
“Other than the
functions.php file (as noted above), any file you add to your child theme will overwrite the same file in the parent theme.”
So technically it should work, I believe you have followed all the WordPress coding standards.
Please let me know your views.
It seems you are misunderstanding the child theme concept.
You can only overwrite template files in the child theme and not js, css or any other custom PHP files that only contain functions.
The theme helpers_blog.php is a functions file and not template file as it contains the theme functions.
You can get more information about WordPress child theme in the below page.