1

Probably a silly one but hopefully someone has encountered this before.

The problem:

I have a local copy of my Wordpress site that works fine and a copy on the server. After uploading I get Call to undefined function from within the child theme's header.php referencing a function that should exist in its parent theme.

Full error message:

Fatal error: Call to undefined function shapely_get_header_logo() in /home/twimp/training.twimp.co.uk/wp-content/themes/shapely-child/header.php on line 33

Background:

The server has recently had a Wordpress site running on it fine so I don't have particular reason to think its anything related to its configuration.

I'm using a different theme from the last time it was uploaded so I started by uploading these two directories, my child theme and its parent. A lot of changes had been made with the plugins so I cleared the plugins directory and re-uploaded everything.

I also completely wiped the database and imported from local and then modified the options table to put the correct server url back in.

wp_config has not been touched and so it still points at the right database.

What I've tried:

I initially thought that maybe a file or two hadn't uploaded so I checked the FTP server side by side, starting with the files it should have been looking at. They all seem to be there.

I thought perhaps it was a file permission problem so I reset all of the files in the wp_content directory.

Just in case I was losing my mind, I have tried making small changes to the header.php just to confirm it is in fact the right file on the right server and the database is looking at the right files. All normal.

I tried commenting out the erroneous function call but all that did was move the error down to the next function called.

I checked the style.css to check its parent declaration was correct. I noticed there is a difference in file size between server and local but I've downloaded the file and it looks correct.

I modified the functions.php on both parent and child simply to var_dump the current user. The child theme printed, the parent theme did not.

Conclusion: It seems as if my child theme is not aware of its parent when on the server but I can't figure out why that might be.

Child theme style.css

/*
Theme Name: Shapely Child
Template: Shapely
Version: 1.1.7
Author: colorlib
Author URI: LINK
*/

Parent theme style.css

/*
Theme Name: Shapely
Theme URI: LINK
Author: colorlib
Author URI: LINK
...
*/

I apologise in advance if I've skipped over anything essential.

Any and all help is greatly appreciated.

  • What's the undefined function? – Jacob Peattie Aug 25 '17 at 9:52
  • Please share the theme name and function name which trigger the error. Maybe that function name is deprecated from parent theme. – maheshwaghmare Aug 25 '17 at 9:58
  • @maheshwaghmare Deprecation does not produce that error. – fuxia Aug 25 '17 at 10:00
  • The undefined function is "shapely_get_header_logo" from the shapely theme but I don't believe that's the issue because it just happens to be the first one in the header.php file that is called and if I comment it out, I just get the same error on the second. – Ross Coombes Aug 25 '17 at 10:14
  • @RossCoombes can you edit your question to contain the full error message? Also, please include the top of style.css so we can check everything needed to do a child theme has been put in place correctly – Tom J Nowell Aug 25 '17 at 11:04
0

Well... I fixed it finally.

I decided to bypass my child theme to try and allow myself to login to the admin system on the server. To do that I went into the database and set both the template and stylesheet options manually to "shapely". Once in, I used the interface to re-select my child theme and voila, my theme now works.

I looked at the source code for switching theme and the options it changes in the database are template, stylesheet, current_theme and theme_switched.

After a bit of trial and error, I was able to replicate the exact problem by changing the case of the template option. Unfortunately I may never know exactly where or how the discrepancy came about but thank you to @maheshwaghmare as you put me on the right track.

  • please remember to accept your answer – Mark Kaplun Aug 28 '17 at 12:38
0

You need to use Template: shapely instead of Template: Shapely

E.g.

/*
Theme Name: Shapely Child
Template: shapely
Version: 1.1.7
Author: colorlib
Author URI: LINK
*/

Template is the directory/folder name on you're parent theme.

For more detail's about child theme @see https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme

I have added this answer instead of cement to highlight and help it other's.

0

For others that end up here, it's important to firstly put the comments in the style.css file of the child theme and secondly to make sure to do it with the correct casings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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