I was installing and setting up the Waverly theme for a client the other day when I came up against a pesky bug. Whenever I enabled the featured posts slider on the blog page settings it would cause the theme to crash, the preloader would spin and spin, and with the preloader turned off you would get the white screen of death below the header.
It turned out that the function being used to grab the featured posts was broken. It was meant to bring out an array containing the featured posts along with configuration options and settings for the slider itself. But the devs had made a boob, they were adding to the configuration options and posts using “array_push”, but the variable they were using already contained an array of WP_Post objects. So as a result when they cycled through that variable after it was returned from the function, trying to use it as an array caused fatal error: Unable to use object of type WP_Post as array” on line 143 of content-featured.php although that was only the first line of many that would trigger that error.
I coded the fix in file waverly/inc/smpixel-class-global.php and you can see it in this Gist. What I did was create the Gist with the original file, then paste in the fixed code, so if you look at the revisions page for the Gist you can see exactly what I did to fix it.
I have contacted the theme authors so they are aware of this fix. Hopefully they will add either my fix or their own to the next release. I will keep you posted here if I hear back from them.
Like the code you see here? You can hire me at Codeable.io - a WordPress specialist outsourcing site that vets developers to make sure they are of the highest standard. See all developers you can hire through Codeable here.