Site logo

Archived topic

Error Adding Filter to Child Theme

13 replies · Started by Leon on August 16, 2017

Viewing posts 1–14 of 14

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
Leon

Hi there,

Can you show me the function you're adding?

Yes.

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/

Hi 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.
Leon

Putting 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.

Hi 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 84

I never changed anything on line one of the child theme php file.

Is there anything I was missing?

Thanks again
Leon

Can 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/

Hi 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

No problem!

Hi Tom,

Kindly check this page for the child theme functions.php file after I paste the filter.
https://pastebin.com/Sn0Eh7nw

Regards
Leon

Hmm, 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.

Thanks 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!
Leon

Glad I could help :)

This archived topic is closed to new replies.