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!

Leave a Comment

Posting Code

We highly encourage you to post problematic HTML/CSS/JavaScript over on CodePen and include the link in your post. It's much easier to see, understand, and help with when you do that.

Markdown is supported, so you can write inline code like `<div>this</div>` or multiline blocks of code in in triple backtick fences like this:

```
<script>
  function example() {
    element.innerHTML = "<div>code</div>";
  }
</script>
```

We have a pretty good* newsletter.