- This topic has 21 replies, 2 voices, and was last updated 5 years, 11 months ago by Tom.
-
AuthorPosts
-
May 15, 2018 at 9:23 pm #576696Sami
Hello, so should everything work if i just copy paste all the custom code from parent theme folders to the child & then remove all the custom code in the parent theme folders?
Also a silly question, but how am i supposed to avoid this from happening in the future? Am i supposed to have the parent theme active and have the custom code there? Or parent theme active?
May 15, 2018 at 9:25 pm #576698TomLead DeveloperLead DeveloperYes, just be sure to completely remove the custom code from the parent theme before saving it in the child theme. PHP functions cannot be redeclared. If they already exist, you’ll run into errors.
It’s best to just leave the parent theme along completely. All custom code should always go into a child theme.
May 15, 2018 at 9:32 pm #576700SamiAnd i should have the child theme as the active theme?
I try to remove all the custom code and add it to the child theme and let you know if i run into issues.
May 15, 2018 at 10:06 pm #576715SamiYeah it didn’t work, bunch of errors this time. Some parts of the website work perfectly now. For example the product page.
The home page is completely broken though..
Here are the errors, all in the functions file:
Your PHP code changes were rolled back due to an error on line 76 of file wp-content/themes/generatepress-child/functions.php. Please fix and try saving again.
Line 76: return $product->get_product_url();
Uncaught Error: Call to undefined method WC_Product_Simple::get_product_url() in wp-content/themes/generatepress-child/functions.php:76
Stack trace:
#0 wp-includes/class-wp-hook.php(286): {closure}(‘https://consume…’, Object(WC_Product_Simple))
#1 wp-includes/plugin.php(203): WP_Hook->apply_filters(‘https://consume…’, Array)
#2 wp-content/themes/generatepress-child/functions.php(58): apply_filters(‘woocommerce_loo…’, ‘https://consume…’, Object(WC_Product_Simple))
#3 wp-includes/class-wp-hook.php(286): woocommerce_custom_template_loop_product_link_open(”)
#4 wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)
#5 wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#6 /home2/drnldkmy/public_hMay 16, 2018 at 8:45 am #577202TomLead DeveloperLead DeveloperThat’s an error within the custom code you had written for you. Your developer needs to check to make sure
get_product_url()
is a valid method.May 16, 2018 at 8:15 pm #577621SamiHello, the website crashed completely now. I don’t think there is anything wrong with the custom code. I have another website that only has different colors logos etc… with the exact same custom code theme plugins and everything and it works fine.
But yeah i don’t think this is going to work. I will boot the whole thing and hire someone to fix it for me.
Can you just answer me is the parent theme supposed to be the active theme or the child theme in order to avoid this from happening in the future?
Thanks for your help.
May 16, 2018 at 9:05 pm #577643TomLead DeveloperLead DeveloperThe child theme needs to be the active theme in order for the code within it to execute.
Sorry I can’t be more helpful – the code itself seems to be the issue.
-
AuthorPosts
- You must be logged in to reply to this topic.