1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

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

Discussion in 'Web Design & Development' started by madar, Feb 11, 2020.

Advertisement
  1. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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?
    WP-Dev-17 - Fatal Error memory size.jpg
     
  2. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,386
    First Name:
    Jim
    Probably not the memory exhaust cause, but why would you want to run the function "wp_enqueue_scripts" twice?
     
  3. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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!
     
  4. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,290
    First Name:
    Colin
    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
     
  5. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,386
    First Name:
    Jim
    Superb(y)
    Unlike Colin, I am not a WP aficionado, but am glad my comment helped ...
    Perhaps you can mark this thread solved?
     
  6. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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!
     
  7. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,290
    First Name:
    Colin
    You have missed the definition for display in your CSS.
     
  8. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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,,
     
  9. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,386
    First Name:
    Jim
    The display property should be display: inline; in order to have horizontal links in your menu;) ( or you could replace display with float:left; )
     
  10. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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!

    WP-css-1.jpg WP-css-2-functions.jpg WP-css-3-home.jpg
     
  11. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,290
    First Name:
    Colin
    are you creating those items using ul and li? if you are then you need this too in your css

    Code:
    ul {display:inline;}
     
  12. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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...
     
  13. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    Here the screenshots:
     

    Attached Files:

  14. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,290
    First Name:
    Colin
    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.
     
  15. madar

    madar Thread Starter

    Joined:
    Feb 2, 2020
    Messages:
    10
    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,,
     
  16. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...

Short URL to this thread: https://techguy.org/1240061

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice