The Value of Tinkering

March 28, 2023

This afternoon, I decided to try to solve a problem that I was unable to solve in November. I wanted to take time to try to solve it because I foresee using this solution again in another project in the future.

I created a WordPress guide for the Energy Efficiency Hub. I built the site with Gutenberg blocks and made several custom blocks for the project. I thought it would be helpful to document how to use those blocks for the client so they can build new pages in the future.

In the past, I had created similar guides within the WordPress administrative dashboard. I found a way to create a new section with subpages. I had to create a new template for each individual page, which was time-consuming. On the Hub project, I wanted to find a better solution.

As I was thinking through some different options, I realized that I already had a powerful page builder at my disposal with Gutenberg blocks. I only had to create a single template and then add Gutenberg blocks to add content to each of the guide pages I needed to create.

I created a new custom post type and added some code to my theme functions file to exclude the WordPress guide custom post type from the site search. I created a separate stylesheet for the guide pages to cover the handful of blocks I was going to use to build the guide pages. I do not include the default Gutenberg block stylesheets in my projects because I write custom code for the layouts that the design solution calls for.

The guide pages included a sidebar table of contents along with previous and next links for each of the pages. I had chosen to use the Reorder Posts plugin that allowed me to order the pages of the guide with a drop-and-drag interface. I was able to list the pages of the guide using the order that the plugin set but I was not able to get the previous and next posts to order correctly.

In the end, I ended up changing the post dates and times of new pages that I added to the guide to fit into the correct order I needed for the guide. It was a “workable” solution but not ideal. But I had to move on to other project work.


Today, I wanted to see if I could find a better solution both for the guide on the Energy Efficiency Hub and for future WordPress guides that I will create. Earlier this year, I needed to add some new pages to the EE Hub guide after I added new functionality to the site. I ended up changing the post dates and times to get the pages to be in the order that I wanted with the previous and next links.

I decided to ask my fellow developers on our internal Slack channel if they had some ideas but they did not respond right away. I have been playing around with ChatGPT this week so I decided to see what it would suggest. I typed in “How to have previous_post_link use menu_order instead of date to get the previous post in WordPress page” into the chat box and then ChatGPT gave a suggestion. I then asked if I could do it per custom post type and ChatGPT gave me an updated solution.

From there, I engaged one of my teammates and he thought that the ChatGPT solution would work. But as I tried it in my codebase, it had no effect. Another one of my teammates got involved and we tried a couple of different things as we talked on Slack and eventually hopped on Zoom for a screen share.

After looking into the query data (with Query Monitor) and looking at the database, we finally came to the conclusion the Reorder Posts plugin was not writing the data to the database that we needed for the filter solutions that we had been trying to work. After about an hour’s work, I still did not have a solution. But I knew there was value in trying.


I decided to try one more thing. As I started the process of exploring a solution this afternoon, I had come across a list of other sorting plugins. I decided to try one of them, Simple Page Ordering. I added the plugin to my local development site. I looked at the database and saw that this plugin was adding the sorting information to the database. I decided to test the guide pages and found that both the sidebar menu and previous and next links were in sync and in the correct order. And I did not have to add any filters to my theme functions file.

I liked the interface of the Simple Page Ordering plugin much better. The Reorder Posts plugin had a separate screen to reorder the pages/posts with drop-and-drag. But the Simple Page Ordering plugin used the page listing in the custom page type and you could drop-and-drag the order of the pages/posts on that screen. I learned that the plugin only works with pages, hierarchical custom post types, or custom post types with “page-attributes” which fit perfectly with the custom post types that I already had on the site.


In the end, I spent about ninety minutes tinkering. I came away from the experience with a better understanding of how two different plugins worked and had a solution that I can use in the future for WordPress guides or similar pages where I had a table of contents and pagination links. I discovered a new plugin that I like much better than the solution I had been reaching for in the past.

Comments are closed.