Archived topic
Child theme file does not overwrite the original
5 replies · Started by Alfonso on June 26, 2020
Good morning.
I have changed the general.php file of the theme's inc folder, but not to change the original theme I have done it in a child theme.
In the child theme I have created the same folder inc and inside I have put the modified general.php file.
The problem is that my website does not read the modified file of the child theme, but keeps reading the one of the parent theme.
The child theme file does not overwrite the original.
Which may be due?.
Best regards.
Hi there,
the general.php cannot simply be overwritten using a child theme.
Most things in GP can be modified using hooks.
What changes are you making to this file ?
Hi.
In the general.php file I want to change the format of the widget-title class. Now is in <h2> and I want to set it in <p>. It's to control the headers structure in my web.
I don't want that all the widget titles have <h2> header. I want them in <p>.
Best regards.
Add this PHP snippet to your functions:
add_filter( 'generate_start_widget_title', 'widget_title_start_tag' );
function widget_title_start_tag()
{
return '<p class="widget-title">';
}
add_filter( 'generate_end_widget_title', 'widget_title_end_tag' );
function widget_title_end_tag()
{
return '</p>';
}
Thank you very much.
You're welcome