In which I detail obscure WordPress tinkering and celebrate doing what happens with a small amount of understanding…

Despite the expected mockery of some harsh critics I’ve been really happy with the change over in August to this newest outer dressing on this blog (do you keep your own history? It’s a good practice if you are in this domaining for the long haul).

One of the features of the parent Cover theme is the ability to have a top sliding banner of selected “featured” posts. This is done by picking a tag you want to use, applying it to posts, and then entering it in the appropriate spot of the customizer

My site will display all posts tagged “marquee” for the top slider of the blog home.

This generally works well, but I had a thought to do something other than put selected posts in the top- I wanted to use it as a way to point to my sites that are elsewhere on the internet.

My aha was to use the Quick Page/Post Redirect Plugin to create a series of posts I could tag to put at the top of the blog, but any clicks will take you to my other sites. You can see the whole set of them at http://cogdogblog.com/tag/marquee/. For example, the “post” for my photo site http://cogdogblog.com/2017/08/barkingdog/

Actually takes you directly to http://barkingdog.me.

Each of these “posts” has a title, the marquee tag, a featured image to make it appear on my site, and then I use the settings for Quick Page/Post Redirect Plugin to create the redirect

The thing I did not like is that the same featured post always appeared first, because they way they are retrieved, as in the tag link, is typical blog newest post first. The only way to change the order is to manually fiddle with the publishing dates.

There ought to be a better way.

A random way.

And thus the code digging begins. I found in the Cover theme template files that it makes use of the JetPack plugin feature for Featured Content.

But as far as I could tell, there are no options/parameters to send the function to change the order in which posts are returned. But… as I could see the way the code works, it requests the featured posts via a function

so what this function returns is simply an array, or an associative array. Maybe I can shuffle the array once it is delivered. The thing about arrays is… there is a built in shuffle function to shuffle ordinary arrays, but to re-order an associative array, you need a little helper function.

As typical IFTHAISA (I Found The Answer in Stack Exchange), so I wrote my own function. Basically, you get the keys for the main associative array, store in new ordinary array, then shuffle that array, then reassign the values based on the keys.

This all goes into the /inc/jetpack.php template of the Cover theme. The original function that gets the featured posts from JetPack is

which I re-write:

The only hitch is that this needed to go into the parent theme because of the way it references the include files. For this case, an update is not a problem because the author is not updating the plugin. But if you every want to keep a theme from being auto updated you can trick it by editing the style.css file in the parent theme and editing the Version value in the top to a crazy high number, like changing the current theme version from 1.8.2 to

WordPress will only update a theme if the version on your site is less than the version on WordPress.

It’s a cheap trick, but it work likes a real (non-bit) gold coin.

And now in testing, I can see that my header featured images are now in different orders. The thing is… you will not see it on a reload because I am using a caching plugin. But keep returning to the front page of this blog, and you should notice it does change.

This is rather a tiny, inconsequential thing, but being able to do the tiny, inconsequential things I know should be doable, and not being limited what a system limits me to, is the most freedom a web tinkerer can ask for.

If I want random, the heck with what the code provides, I can get it myself.


Featured Image: Random Number Multiples – RGB flickr photo by blprnt_van shared under a Creative Commons (BY) license

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for cogdog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.

Leave a Reply

Your email address will not be published. Required fields are marked *