# How to fix this error: Fatal error allowed memory - WP



## madar (Feb 3, 2020)

Hey tech guys,
was following course of developing WP theme,
my OS: windows 10 pro, 64-bit
Localhost server: Laragon
All steps were going fine, till reached to add some code to the file name:
functions.php 
See the code in below
---------------------------------
<?php

function load_css()
{

wp_register_style('bootstrap', get_template_directory_uri(). '/css/bootstrap.min.css', array(), false, 'all' );
wp_enqueue_style('bootstrap');

}
add_action('wp_enqueue_scripts', 'load_css');

function load_js() 
{
wp_enqueue_scripts('jquery'); 
wp_register_script('bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', 'jquery', false, true);
wp_enqueue_script('bootstrap');
}
add_action('wp_enqueue_scripts', 'load_js');

---------------------------------
Installed bootstrap and dragged css, js folder inside the new theme folder,
when loaded the home page, seen an error saying:
=========
*Fatal error*: Allowed memory size of 3145728000 bytes exhausted (tried to allocate 262144 bytes) in *C:\laragon\www\test\wp-includes\cache.php* on line *544*

*Fatal error*: Allowed memory size of 3145728000 bytes exhausted (tried to allocate 262144 bytes) in *Unknown* on line *0*
=========
and when remove the code from the functions.php page it turns to work fine with no errors,

I checked the root files, but could not find a solution to fix this,
anyone have an idea how to fix this error plz?


----------



## JiminSA (Dec 15, 2011)

Probably not the memory exhaust cause, but why would you want to run the function "wp_enqueue_scripts" twice?


----------



## madar (Feb 3, 2020)

JiminSA said:


> Probably not the memory exhaust cause, but why would you want to run the function "wp_enqueue_scripts" twice?


As mentioned, I was following a training,
but, I removed this: wp_enqueue_scripts('jquery');
and worked properly, was troubled the whole day with this issue, 
Thank you very much... indeed was so helpful,
highly appreciated!


----------



## colinsp (Sep 5, 2007)

jQuery is already part of Wordpress so is not needed. Watch what you call functions, they should have a name specific to your project be it a theme or a plugin, so as not to conflict with other themes, plugins or Wordpress itself. So call them something like ma_load_css


----------



## JiminSA (Dec 15, 2011)

madar said:


> I removed this: wp_enqueue_scripts('jquery');
> and worked properly, was troubled the whole day with this issue,
> Thank you very much... indeed was so helpful,
> highly appreciated!


Superb
Unlike Colin, I am not a WP aficionado, but am glad my comment helped ...
Perhaps you can mark this thread solved?


----------



## madar (Feb 3, 2020)

really appreciate your help guys: JiminSA, colinsp,
I'm following a training WP theme development, 
again today, another error happened, I will copy the entire code in the filename: main.css
this code was to display the navigation bar to be horizontal, 
currently the menu bar like this:
Home
About us
Contact us

This code to display is like this in below: 

Home | About us | Contact us
-------------------------------
header .top-bar {
list-style-type: none; 
margin: 0;
padding: 0;
display: ; 
}
----------------------------
As shown in the training, the menu changed to be in horizontal after saved and refreshed the page,
but the code did not implement at my side, 
any wrong or something missing?
Thanks again!


----------



## colinsp (Sep 5, 2007)

You have missed the definition for display in your CSS.


----------



## madar (Feb 3, 2020)

colinsp said:


> You have missed the definition for display in your CSS.


header .top-bar {
list-style-type: none; 
margin: 0;
padding: 0;
display: flex;

Was this,, and still... but did not change the menu to be horizontal,,


----------



## JiminSA (Dec 15, 2011)

The display property should be display: inline; in order to have horizontal links in your menu ( or you could replace display with float:left; )


----------



## madar (Feb 3, 2020)

JiminSA said:


> The display property should be display: inline; in order to have horizontal links in your menu ( or you could replace display with float:left; )


Thanks JiminSA, 
I tried your suggested scripts, but it didnt work, even I searched ay w3 schools - tested all the menu style codes, but still the same vertical menu,
However, I will take some screenshots for my main.css file, and functions.php, also for the home page (test) to give a clear picture, maybe will be helpful to detect where is the missing part or the error,
please find the attached files after this, with many thanks in advance for your help tech guys!


----------



## colinsp (Sep 5, 2007)

are you creating those items using ul and li? if you are then you need this too in your css


```
ul {display:inline;}
```


----------



## madar (Feb 3, 2020)

the top menu: home, about us, contact us
these created pages assigned to the top-menu list, 
but the code didn't help to display them horizontally, 
unfortunately...


----------



## madar (Feb 3, 2020)

colinsp said:


> are you creating those items using ul and li? if you are then you need this too in your css
> 
> 
> ```
> ...


Here the screenshots:


----------



## colinsp (Sep 5, 2007)

Don't keep pasting screenshots paste the code in code tags that is the funny icon to the left of the disk icon in the tool bar. We need to see more of your code.

*BUT for now just add my suggested code into your CSS and lets see what happens it should fix the problem.*


----------



## madar (Feb 3, 2020)

colinsp said:


> Don't keep pasting screenshots paste the code in code tags that is the funny icon to the left of the disk icon in the tool bar. We need to see more of your code.
> 
> *BUT for now just add my suggested code into your CSS and lets see what happens it should fix the problem.*


I tried your code,,, it didnt fix the issue,, that's why i replied and attached the screenshots to make the whole topic clear that nothing is missing or implemented incorrectly, 
I tried all the below codes as shown in screenshots,, but nothing changed,, 
================
header .top-bar {
list-style-type: none; 
margin: 0;
padding: 0;
display: flex; 
}
---------------------
header .top-bar {
list-style-type: none; 
margin: 0;
padding: 0;
display: inline-flex; 
}
----------------------
header .top-bar ul {
list-style-type: none; 
margin: 0;
padding: 0;
display: inline; 
}
==============
the attached screenshots in above shown the pages (top menu) and how displayed in the test home page,,


----------



## JiminSA (Dec 15, 2011)

Can we see your html for the menu, please?
(You can use the 4th icon from the right to paste it in to a readable TSG format)


----------



## madar (Feb 3, 2020)

JiminSA said:


> Can we see your html for the menu, please?
> (You can use the 4th icon from the right to paste it in to a readable TSG format)


There is no any HTML,,, all coding in php and css - as inserted the bootsrap,
if you look at the above (previous) posts screenshots will see all files are php format, - wordpress developing theme, 
anyway,, thanks for the efforts!


----------



## JiminSA (Dec 15, 2011)

If you right-click on your page in the browser and choose 'view source', you can copy the relevant html for us please? This code may well point us to the problem ...


----------



## colinsp (Sep 5, 2007)

Professionalgirl said:


> HiJimin, Have you tried upgrading to the Genesis 1.8.0 version? If not that may be why your unable to display a horizontal menu bar. According to Jornalexra.com, "The older version only supports vertical menu bars." Please refer to this site link for the fix https://journalxtra.com/wordpress/genesis-1-8-0-released-menu-widgets-dreprecated-fix/ and make sure you add any missing code that you may have forgotten before compiling the code such as the ) should have a ; at the end. Just one tiny mistake in your spelling or forgetting a small piece of code can cause fatal errors or endless looping. Please carefully inspect your code thoroughly and with sharp perception and observation before implementing. Also, you may want to run a debug tool if it's available for this type of coding.


Tina

Madar is writing his own theme and so your advice is incorrect as that link is referring to the Genesis theme.


----------



## Professionalgirl (Jan 10, 2020)

colinsp said:


> Tina
> 
> Madar is writing his own theme and so your advice is incorrect as that link is referring to the Genesis theme.


Okay Madar, No problem.


----------



## Cookiegal (Aug 27, 2003)

That's not Madar, it's Colin. Madar is the person seeking assistance creating their own theme. Colin has been helping and he's the one who addressed you about your response.

I'll delete your other post since you edited it and again addressed the wrong person so out of sequence it makes no sense.


----------



## Professionalgirl (Jan 10, 2020)

Thanks for point that out to me I addressed the wrong person by mistake. I did not intend to. From now on I will not post anything. I will just read.


----------



## Cookiegal (Aug 27, 2003)

It's just a matter of reading the entire thread to be sure you know the actual issue and sometimes you have to go back and read posts again and again especially in lengthy threads. Generally speaking though, when you see one or two experts are already involved in assisting someone in any of the threads it may be best to just follow along and not intervene unless they are unable to solve the issue and you truly believe you have the solution.


----------



## Professionalgirl (Jan 10, 2020)

Cookiegal said:


> It's just a matter of reading the entire thread to be sure you know the actual issue and sometimes you have to go back and read posts again and again especially in lengthy threads. Generally speaking though, when you see one or two experts are already involved in assisting someone in any of the threads it may be best to just follow along and not intervene unless they are unable to solve the issue and you truly believe you have the solution.


Hi Cookigal, I do try carefully reading the posts and also try not to respond when other techs are helping to resolve this issue. I Think I am jumping in too soon and I shouldn't do that. It could be that I haven't had much sleep lately and I am making all these embarrassing mistakes.


----------



## JiminSA (Dec 15, 2011)

Professionalgirl said:


> It could be that I haven't had much sleep lately and I am making all these embarrassing mistakes.


Don't be embarrassed, Tina. We realised that your input was well intended


----------



## Professionalgirl (Jan 10, 2020)

Awe Thanks JiminSA for your kind thoughts. 
I keep making more mistakes than most others though.


----------



## Johnny b (Nov 7, 2016)

I suggest the 'coffee' excuse.....as in not enough.
But having a hole in my head also works


----------



## JiminSA (Dec 15, 2011)

JiminSA said:


> If you right-click on your page in the browser and choose 'view source', you can copy the relevant html for us please? This code may well point us to the problem ...


@madar - this still applies ...


----------



## JiminSA (Dec 15, 2011)

Having just discovered this fact about display:block; ...
*display: block;* means that the element is displayed as a block, as paragraphs and headers have always been. A block has some whitespace above and below it and tolerates no HTML elements next to it, except when ordered otherwise (by adding a float declaration to another element, for instance).
I strongly recommend that you try it and disregard my previous suggestion.


----------



## vibhutitechnologies (Jul 8, 2019)

Background Information About PHP Memory Limit - 

PHP Memory limit sets the maximum amount of memory in bytes that PHP allows to allocate to a script. This prevents poorly written scripts for eating up all available memory on a server.

In most cases, if you get a memory limit error it's due to a faulty plugin. If you're at 32 or 64 M limit, that should be more than enough.

If you set it to 128 M and still getting the error, then you for sure know it's due to a faulty plugin. So the key question is what plugin did you install prior to this?

Things to Try -

Try adding this line to your wp-config.php file:
define('WP_MEMORY_LIMIT', '128M');
If you have access to your PHP.ini file, change the line in PHP.ini
If your line shows 32M try 128M:
memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
If you don't have access to PHP.ini try adding this to an .htaccess file:
php_value memory_limit 128M

Please try these then let us know!!


----------

