Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress WordPress Theme Development WordPress Header and Footer Templates Porting existing headers and footers into WordPress

John Nichols
John Nichols
1,451 Points

wp_head(); is causing memory error.

wp_head() is causing this error: "Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 4096 bytes) in /Users/jn/Sites/localwp.com/wp-includes/class-wp-hook.php on line 291"

The error only starts when I add that line.

I have already tried:

Changing "define( 'WP_MEMORY_LIMIT', '256M' );" in wp-config.php and Changing "memory_limit = 256M" in MAMP>bin>php>php7.0.15(version I'm using)>conf>php.ini

I'm completely out of ideas.

My functions.php:

<?php 

function wpt_theme_styles() {

    wp_enqueue_style('foundation_css', get_template_directory_uri() . '/css/foundations.css');
    wp_enqueue_style('normalize_css', get_template_directory_uri() . '/css/normalize.css');
    wp_enqueue_style('normalize_css', 'http://fonts.googleapis.com/css?family=ASAP:400,700,400italic,700italic');
    wp_enqueue_style('main_css', get_template_directory_uri() . 'style.css');
}
add_action('wp_enqueue_scripts', 'wpt_theme_styles');

function wpt_theme_js() {

    wp_enqueue_scripts('modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false);
    wp_enqueue_scripts('foundation_js', get_template_directory_uri() . '/js/foundation.js', array('jquery'), '', true);
    wp_enqueue_scripts('main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true);
}
add_action('wp_enqueue_scripts', 'wpt_theme_js');

?>

1 Answer

I would deactivate any/all plugins and go one at a time. I have run into this issue with poorly written plugins in the past.

Though sometimes it is due to the memory limit being low.

Did you confirm that the limit did in fact increase to 256? On the server level you generally need to restart it for the setting change to take affect?