Fighting With WordPress

A piece of WordPress coding that I thought would take about fifteen minutes ended up taking close to an hour and a half.

I switched my blog theme recently from Twenty Seventeen (well, a child theme of it) to Shoreditch (again, a child theme of it, albeit one that I worked on in a flurry of activity in May 2016 and then didn’t touch again). Shoreditch has a featured posts slider, and I was curious about it.

Well, I can’t get it to work the way it’s supposed to — it’s supposed to pull six posts with a specific tag, but for some reason it’s pulling my six most recent posts — but that’s a problem I will dig into.

The vexing thing, for me, was that for a slider, it didn’t slide. If you want to see the six most recent posts, you have to click on tiny buttons beneath the slider to go through them. I did some digging into the Shoreditch code, and I found what was controlling that, a js file that the parent theme loads.

That’s editable, I thought, into what I want. But since it’s bad form to edit the parent theme’s files — potential future upgrades would wipe out any changes I made — I knew I had to code a similar js file for my child theme, then “unload” (either by deregistration or denqueueing) the parent theme’s js.

I thought this would take about fifteen minutes. How hard could it be?

Well, it turned into an hour and a half of trial-and-error. What happens if I deregister this script? The slider, for some reason, won’t load. What if I denqueue that? Now the page has a fatal error. What if I remove this action (ie., tell WordPress not to bother with the function that loaded the scripts in the first place)? Nothing.

I had to experiment with various permutations of denqueue and deregister and even load priorities, and finally I found a combination that worked.

So, for all that effort, the slider slides. It’s not showing the content I want it to show, but there’s a slider, and it’s sliding.

The content I want? That’s a problem to solve another day. The easiest solution there will probably be to write a loop with the same output format and avoid the Jetpack issue altogether.

I don’t even remember why I gave up on Shoreditch two years ago.

Published by Allyn

A writer, editor, journalist, sometimes coder, occasional historian, and all-around scholar, Allyn Gibson is the writer for Diamond Comic Distributors' monthly PREVIEWS catalog, used by comic book shops and throughout the comics industry, and the editor for its monthly order forms. In his over ten years in the industry, Allyn has interviewed comics creators and pop culture celebrities, covered conventions, analyzed industry revenue trends, and written copy for comics, toys, and other pop culture merchandise. Allyn is also known for his short fiction (including the Star Trek story "Make-Believe,"the Doctor Who short story "The Spindle of Necessity," and the ReDeus story "The Ginger Kid"). Allyn has been blogging regularly with WordPress since 2004.

Leave a Reply

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