Grey Lynn 2030

Grey Lynn 2030 wanted to update their WordPress website to a new, more modern, and responsive theme, and incorporate their new branding. They chose the Newspaper6 theme from tagDiv for its appearance and ease of use, and asked me to set it up, with graphic design input from Isla Osborne, who was also responsible for redoing their branding.

Most of the customisation could be done by selecting the relevant options from the the theme’s settings panel, e.g. setting accent colours, choosing predefined page layouts, adding custom css. However there were some things which required me to add functionality. For example the client wanted the large grid on the front page to show a fixed set of pages. While the theme allowed the grid to show pages rather than posts, the only choices for selecting which ones were category, tag or author, and the only choices for controlling the order were sorting alphabetically, randomly, by popularity or by highest rating. To get around this I hooked into the pre_get_posts filter and converted the “highest rating” option to sort by WordPress’s built-in page order instead, ignoring all pages where the order was not set. This allowed me to specify which pages to show, and the order to show them in, simply by setting the page order values to 1,2,3 etc for these pages. Hooking into another filter allowed me to change the  “highest rating” label in the dropdown to “page order” to make it clearer how these pages were being sorted.

The Newspaper6 theme is a very visual one and makes heavy use of featured images. Grey Lynn 2030’s previous theme did not, so I wrote a function which went through and set the first image from each existing post as the featured image. This saved having to do it manually for over 500 posts! I also set  the same to happen for new posts when they were first saved, so that an image would be set even if the post author forgot to. As a final backup I added code to the get_post_metadata filter to get a fallback featured image if the post did not contain any images. To make it easier for the client to change this fallback image I added a setting to the media page which calls the default WordPress media manager window. It was surprisingly tricky to get this integrated – Shiba’s tutorial was the most helpful, though even this did not fully explain how to set the modal_update_href parameter.

Grey Lynn 2030 have a large number of categories on their website, and they wanted the sidebar widgets to show recent posts or recent comments only for the current category. While there are plugins providing widgets which do this if you are viewing a Category, they don’t work if you are on a Page which includes posts via a secondary query, which was the situation here. I was able to restrict the built-in Recent Posts and Recent Comments widgets to the desired category by hooking in to the widget_posts_args and widget_comments_args filters and setting the category argument based on that specified in the meta values for the current page. I also wanted to add dates to the recent comments widget, which turned out to be tricky as it doesn’t have any means of filtering its output. To get around this I used the ingenious method of Philip Newcomer which adds a filter to the output of any widget.