Cannot redeclare class Sydney_Employees

Hi,

I’m working with a child theme of sydney template. I made some modifications to the employee file in the child theme and when I loaded the functions.php into my child folder, I get a fatal error message:

“Fatal error: Cannot redeclare class Sydney_Employees in C:\xampp\htdocs\sitefoocus\wp-content\themes\sydney\widgets\fp-employees.php on line 197”

How i do to fix it directly in child’s archives for don’t lose my data when the page update?

Thanks!

Hi,

Please open functions.php file in sydney theme (not the child theme) and change this line:
require get_template_directory() . "/widgets/fp-employees.php";

to:
// require get_template_directory() . "/widgets/fp-employees.php";

Regards,
Awan

Hi Awan,

If I modify directly the Sydney Theme when updating the Theme my site will crash!

How can I do it so that it does not happen? Is there any way to do directly in the functions.php of the my child?

Best,

Hi,

The double slash // on the code in above will not make your site crash, those double slash are used to disable on calling Sydney_Employees class in main theme and it can be done from the child theme.

But, I suggest you to edit the PHP file using FTP not from wordpress editor.

Hi,

I know that double slash are used to disable but if I edit directly in the Sydney theme, I lost the date when update the Theme. If I update the Sydney theme the function.php file edited for me in parent theme (… \ wp-content \ themes \ sydney \ functions.php) will be overwrite.

How can I do it directly in the functions.php of the my child theme?

Thank you so much,

No, you can’t disable on calling Sydney_Employees class from the child theme. You have to do it directly in the parent theme.

Thanks Awan! To clarify, does this mean that every time there was a Sydney theme update, those changes would have to be redone by me?

yes. those part should be change manually every time you update the theme.

You could simply change the class name to something else and register that instead. Then you can use that new widget and not have to worry about updates.

Hi Vlad,

Truth? How can I do this? Can you help me with that?

Thank you so much!

Best

I’m not really sure what you have so far? So you’re loading the widget file from your child theme and are you registering the widget in your child theme using register_widget?

See how it’s done in the parent theme. Basically you would need to change the class in your child theme from Sydney_Employees to something like Sydney_Employees_Custom and the register it in the child theme with register_widget(‘Sydney_Employees_Custom’).