Call to undefined function get_template_part()

I’m getting the following error on my site:

2014-10-28 20:24:20.000 UTC
www: PHP Fatal error: Call to undefined function get_template_part() in /var/www/ on line 1

Not really sure what changed or when this started happening. The page exists.

What happens when you go to index.php and comment out the get_template_part()?

I highly doubt this is a Roots issue.

If you are getting an error on a main WordPress function, you have something seriously wrong with your installation. And @cfx is right, it’s not a Roots issue, it’s a WP setup issue.

1 Like

This is really weird. I am getting the same issue on all my roots sites but only locally. The live deployed ones do not have the issue. Also on all local installs I have tested the default themes and there are no errors. When switching back to roots I get the above. The even more strange thing is that this only happens in the background. The theme still works and displays perfectly normal. I only see the error within the chrome console and if I navigate directly to the theme index file.

Ok now check out the screenshot. If I clear the theme’s index.php file, no error. Also please note in both cases even though I get the error, it only shows up in the console and not within the page source. Also the site runs perfectly whether or not I clear the index.php file.

How is it displayed in the Chrome console? PHP errors are not displayed in the Chrome console, as far as I know…

If you are navigating directly to the theme index.php file via the Chrome console, then you are only loading that file, not all of WP, so yes, you’ll get an error.

No that shows up on all pages but only in the chrome console and only with roots and only on local. It makes no sense to me. It must be a php configuration issue but it is definitely only happening on my roots sites.

Do you have a plugin installed? A PHP fatal error would be displayed on the page and all content below it would not be shown (because PHP effectively stops). So I’m confused how you are seeing a fatal error of PHP in the console but yet the page loads fine.

Hey all. Figure out the issue. Really odd. So I had declared respond.js in my $assets array but only for the live environment. I guess this was calling some kind of warning somewhere that was leading to an error. It is now fixed as I added it in for my dev environment as well.

Thanks @kalenjohnson for the help.

function roots_scripts() {
 * The build task in Grunt renames production assets with a hash
 * Read the asset names from assets-manifest.json
if (WP_ENV === 'development') {
	$assets = array(
		'css'       => '/assets/css/main.css',
		'js'        => '/assets/js/scripts.js',
		'respond' => '/assets/js/vendor/respond.min.js',
		'modernizr' => '/assets/vendor/modernizr/modernizr.js',
		'jquery'    => '//'
} else {
	$get_assets = file_get_contents(get_template_directory() . '/assets/manifest.json');
	$assets     = json_decode($get_assets, true);
	$assets     = array(
		'css'       => '/assets/css/main.min.css?' . $assets['assets/css/main.min.css']['hash'],
		'js'        => '/assets/js/scripts.min.js?' . $assets['assets/js/scripts.min.js']['hash'],
		'respond' => '/assets/js/vendor/respond.min.js',
		'modernizr' => '/assets/js/vendor/modernizr.min.js',
		'jquery'    => '//'

You really should be adding Respond via your Gruntfile: Respond.js: how to get it working?

Sorry for the super long delay here. Not sure why I didn’t get any updates on this. Oops.

I’m guessing Respond was added after my version. I’m running version 6.5.2. Updating is not ideal as I’ve heavily customized it at this point. Not really sure what else I should be looking at here. Default themes that use get_template_part work but not on Roots.

Looks like it was an issue with the upload of the theme. I re-uploaded it and it seems to work now. Perhaps a corrupted file? Who knows. Just glad I got my theme back up :smiley:

1 Like