This is an extra special RETURN OF THE JEDI themed episode of the v10 redesign series!

We left the last screencast utterly defeated. We were trying to use wp_list_pages() to output some navigation for the homepage of our Almanac section. One of our calls to it worked, the other didn't. We tried all kinds of stuff to get it to work, everything failing. The Empire was knocking at our door.

In this screencast, we've taken a bit of a break, cleared out heads, and approached the problem fresh.

The error we ultimately discovered was that the program was running out of memory. We we either need to have it use less memory (probably too hard, we aren't WordPress core devs here) or give it more memory. We opt for the latter.

WordPress by default uses 32MB of memory. In our wp-config.php file, we double that by adding:

define('WP_MEMORY_LIMIT', '64M');

I confirmed this with a WordPress core dev - this isn't a bad thing to do at all. They said in fact it's about time for them to up the default memory usage anyway. My server has many GB of memory, so this should not be a problem.

As soon as that is in place, the second wp_list_pages() immediately starts working.

We should throw up a little bit of a yellow flag here and just note that if we have memory problems on the server, we should watch this page. I'm extra not worried though, because 99+% of the time this page will load, it won't actually be running these functions and hitting the database and all that, it will be a static copy being served up by our caching setup.

Yay we did it!

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.