w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Is there a way to automatically install a wordpress parent theme when installing a child theme?

When a theme is installed it is run through the check_parent_theme_filter() function which ensures that the parent theme is installed. If it is not and it cannot be fetched from the WordPress repository then the install fails with the message keyed on parent_theme_not_found.

If this parent theme is not installed on the WordPress repository, you will need to use the hooks available in themes_api() which is the function WP uses to automatically install parent themes. The initial request is failing, however the response is passed through the themes_api_result filter with three arguments: $res, $action, $args. You can use this method as an example of the type of function that you would hook to this filter, returning true if you were able to successfully download and install the parent theme, false if it fails.

Unclear on how to hook to these using a child theme, perhaps a custom plugin would do it?





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.