- This topic has 13 replies, 2 voices, and was last updated 6 years, 8 months ago by Tom.
-
AuthorPosts
-
August 16, 2017 at 9:34 pm #367705Leon
Hi Tom,
I’m using child theme’s functions.php to add a filter. But after that, my website turns into a white blank page. 500 internal error.
Those code are the ones I used to put in to functions.php in main theme and they worked before.
Is there anything wrong with my method please?
(right now I already restored the default functions.php file from your new black child theme to make the website work. But the function I needed was not added yet)Thank you
LeonAugust 16, 2017 at 11:04 pm #367733TomLead DeveloperLead DeveloperHi there,
Can you show me the function you’re adding?
August 16, 2017 at 11:07 pm #367736LeonYes.
add_filter( 'upme_profile_display_user_pic', 'upme_profile_display_user_pic', 10, 2); function upme_profile_display_user_pic($display,$params){ $display .= '<div class="upme-field upme-view upme-user_pic"> <div class="upme-field-type"> <i class="upme-icon-camera"></i> <span>' . __('Profile Picture','upmehooks') .'</span> </div> <div class="upme-field-value"> <span><img src="' . get_user_meta($params['user_id'], $params['meta'] ,true) . '" /></span> </div> </div>'; return $display; }
It’s from this page: http://profileplugin.com/display-profile-picture-custom-field/
August 16, 2017 at 11:10 pm #367737TomLead DeveloperLead DeveloperHmm, the code looks fine.
Make sure the top of your functions.php file starts with:
<?php
Otherwise, use one of the methods here: https://docs.generatepress.com/article/adding-php/
August 17, 2017 at 12:37 am #367765LeonHi Tom,
Wierd. I put those code in functions.php file from GP main theme and it works.
Code snippet causes white page also.
Anyway, I’ll stick to it now as long as it works.
Thanks for your time.
LeonAugust 17, 2017 at 9:07 am #368047TomLead DeveloperLead DeveloperPutting it into the main theme isn’t the best method, as you’ll lose it when you update.
If you check your error_log file, it should tell you the exact error.
August 18, 2017 at 6:39 am #368668LeonHi Tom,
I believe this is the error log for adding that filter to generatepress child theme.
[17-Aug-2017 03:53:35 UTC] PHP Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in /home1/bestchi7/public_html/interpreterdatabase/wp-content/themes/generatepress_child/functions.php on line 1
[17-Aug-2017 03:58:16 UTC] PHP Parse error: syntax error, unexpected end of file in /home1/bestchi7/public_html/interpreterdatabase/wp-content/themes/generatepress_child/functions.php on line 1
[17-Aug-2017 04:22:27 UTC] PHP Parse error: syntax error, unexpected ‘add_filter’ (T_STRING) in /home1/bestchi7/public_html/interpreterdatabase/wp-content/themes/generatepress_child/functions.php on line 1
Below error log for code snippet.
[17-Aug-2017 07:21:03 UTC] PHP Warning: require_once(/home1/bestchi7/public_html/interpreterdatabase/wp-content/plugins/code-snippets/php/class-code-snippets.php): failed to open stream: No such file or directory in /home1/bestchi7/public_html/interpreterdatabase/wp-content/plugins/code-snippets/code-snippets.php on line 84
[17-Aug-2017 07:21:03 UTC] PHP Fatal error: require_once(): Failed opening required ‘/home1/bestchi7/public_html/interpreterdatabase/wp-content/plugins/code-snippets/php/class-code-snippets.php’ (include_path=’.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear’) in /home1/bestchi7/public_html/interpreterdatabase/wp-content/plugins/code-snippets/code-snippets.php on line 84I never changed anything on line one of the child theme php file.
Is there anything I was missing?
Thanks again
LeonAugust 18, 2017 at 9:41 am #368783TomLead DeveloperLead DeveloperCan you paste your entire child theme functions.php file (with the filter added) into a pastebin so I can check it out?: https://pastebin.com/
August 21, 2017 at 10:32 am #370556LeonHi Tom,
Sorry for the late reply. I was struggling with VPN these days as I can’t access your site directly from China.
I will paste the code tomorrow.
Appreciate your help.
Leon
August 21, 2017 at 10:50 am #370576TomLead DeveloperLead DeveloperNo problem!
August 22, 2017 at 2:04 am #371011LeonHi Tom,
Kindly check this page for the child theme functions.php file after I paste the filter.
https://pastebin.com/Sn0Eh7nwRegards
LeonAugust 22, 2017 at 8:53 am #371308TomLead DeveloperLead DeveloperHmm, nothing wrong there – just tried it in my test child theme.
Can try removing everything except for the opening
<?php
, and save.Then re-add the code only.
August 22, 2017 at 9:11 am #371336LeonThanks Tom. I tried it. Looks like it’s working now. I’ll wait for the next GP update and see if it still works. Right now I’m happy with it.
Thank you so much for your patience and great help!
LeonAugust 22, 2017 at 11:48 pm #371691TomLead DeveloperLead DeveloperGlad I could help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.