0

0

I'm in a bit of a struggle at the moment so I could use some help.

The thing is, I need to fix some fields for registration in the Eduma theme Eduma theme has it's own child theme called Eduma-child, and it's using plugins like Thimpress and Learnpress

As I understand, when you want to make changes, you copy files from the parent theme into the child theme and make customizations in there, but after I copied contents of:

/eduma/inc/widgets/login-popup

/eduma/inc/widgets/login-form

/eduma/inc/widgets/form-login-register.php

into the child theme and made changes, I can't see the changes.

This is what I did afterwards to confirm what is loaded:

  1. I echoed "This is parent theme" in login-popup/base.php in parent theme and "This is child theme" in /login-popup/base.php in Child theme

  2. Echoed "Parent theme" in form-login-register.php in parent theme and "Child theme" in child theme

The result:

I only see "This is parent theme" and "Parent theme"

Can someone please explain how this works as I'm baffled by the Wordpress customisation and I'm in a bit of a hurry.

I looked around, googled and it seems to me that widgets aren't customizable in a way like templates are?

0

3 Answers 3

0

As I understand, when you want to make changes, you copy files from the parent theme into the child theme and make customizations in there, but after I copied contents of:

That's not how child themes work or what they're used for.

A child theme can replace a WP template and it can load additional code. Templates specifically are those files that are mentioned in the template hierarchy, and loaded using functions such as get_template_part.

You cannot replace arbitrary PHP files or assets this way, and while WordPress will load the functions.php of both the child and parent themes, it has no idea if they are individual files or if they load thousands of other files, or what their purposes are. They're all loaded into the same melting pot of code along with plugins and WP core itself.

This means whatever you do in a child theme, your parent theme is still going to do what it's already doing unless you modify that parent theme. Some theme authors might provide hooks and settings that let you change this, but they're unique to each individual theme and developer, assuming the developer added them at all.

This means that overriding a widgets output is the same wether that widget is in a child/parent theme or even a plugin, there is no difference.

How To Override A Widget.

If you want to override a widget, it doesn't matter if it's in a parent theme, child theme, or plugin, there are two methods:

  1. Unregister the widget and register it again using your own copy that has modifications
  2. If the author of the widget has provided filters and hooks you might be able to use them to modify the widget. You will need to check the code or documentation as this is unique to each widget, and isn't always possible.

This question/answer will help: How to override / customize existing Widgets?

0

Try this: Modify the Functions File: In your child theme, you may need to modify the functions.php file to explicitly tell WordPress to use your customized widget files instead of the parent theme’s. Deregister and Reregister Widgets: If these files are for widgets, you might need to deregister the parent theme's widgets and then register your own versions from the child theme. This can be done in your child theme's functions.php file. Use Actions and Filters: If the parent theme uses actions or filters for these widgets, you can utilize them to modify the widgets without needing to override the files directly. Example Code: In your child theme's functions.php, you could add something like this:

function wpb_custom_widget_registration() {
    // Deregister specific parent theme widget
    unregister_widget('Parent_Theme_Specific_Widget');

    // Register your custom widget (make sure you've defined this class in your child theme)
    register_widget('Child_Theme_Custom_Widget');
}
add_action('widgets_init', 'wpb_custom_widget_registration');
-1

Ensure that the child theme is activated and that WordPress recognizes it. You can check this in the WordPress admin under "Appearance" > "Themes."

In WordPress, child themes are typically used to override or extend the functionality of a parent theme. However, not all parts of a theme are easily customizable through the child theme. In your case, it seems like the files you're trying to customize are related to widgets and forms, and there might be additional considerations.

Here are a few things to check:

File Structure:

Make sure you've copied the files to the correct location in the child theme. For a child theme named eduma-child, the path should be something like eduma-child/inc/widgets/. Check for Widget Registration:

Widgets are often registered in the theme's functions.php file. If a widget is registered in the parent theme's functions.php file, you might need to re-register or modify it in the child theme's functions.php file.

1
  • Thank you, will try it and get back to you. I tried require_once for the files in question, but it just broke the app as the Widget class from parent theme didn't create an instance of the object I need.. Commented Jan 23 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.