Bunny and Spoon is a food blog I made for Audrey. It’s weird, she refers to herself as “The Bunny” on there, but it’s cute. It was fun and I learnt a lot making it, I hope she’ll use it often. As an asside, I used Affinity Designer to make this bunny: , it’s a wonderful app by a wonderful company. They actually strive to make good software, not just line their pockets like some other companies out there *cough* Adobe *cough*. The price is extremely reasonable so I went ahead and bought a copy. Here’s a screenshot of Bunny and Spoon:
It’s a standard Wordpress site, with a custom made template that features a Mapbox map. Her posts are displayed as bunny paws () on the map. Clicking on a map-marker, or paw, displays a popup preview of the post. Clicking read more then gets the corresponding post using AJAX and displays it on the same page in a div element i.e. without reloading the page. In the brief seconds as it’s loading, there’s a gif loading animation involving chopsticks and a spoon (The Bunny’s trusty tool and our deuteragonist in this adventure). BTW: getting AJAX to work in Wordpress was a nightmare, but once the hair pulling was done it was an easy fix - more on that later.
I used hash marks at the end of the URL or fragment identifiers - as I just learnt they are called - to point to the page or post currently open in the browser. This lets people share posts by copying the link: So
bunnyandspoon.com/#about links to the about page and
bunnyandspoon.com/#2016/10/06/graduation-dinner/ links to Audrey’s first (and only - at the time of writing) post, about her graduation dinner.
Bunny and Spoon is hosted on AWS, which is working pretty fine for now. I’m very satisfied with the usability and the experience, and I’m especially happy with the first free year.
Now back to Wordpess’ AJAX issue: if you make your own PHP file (see below) and try to get data from it using AJAX, wordpress will throw a 404 error in it. What’s frustrating is that if you view the PHP file in your browser it actually shows the data! But upon inspecting the page you’ll see a 404 in the header.
So after hours of bashing my head into a wall, I found that what you’re meant to do is to pass all your custom AJAX requests through:
/wp-admin/admin-ajax.php, including the name of your custom function that will handle this request in the data section: in this case it’s
Or, in the case of Bunny and Spoon, using the Mapbox API to add the data into the map:
And then, include the function to handle the request into your theme’s
And BOOM! It works!
Check out Bunny and Spoon for more food and less code.