How I used WordPress Categories for an Organization’s content structure

There are many different ways to organize content in your WordPress installation. Not one method can be considered the best and only way to create a structure. You have to look at the goal you want to achieve and choose what you think will be best for you. This is how I used the categories of a WordPress site in order to organize the content of a local chapter of a professional organization.

This may not be the ideal setup for how I think the content given me is to be structured. I had the choice and also tested creating a custom post type for the Board Member Bio pages. This worked very well but I feel was a more advanced topic and I wanted to see if I could accomplish something similar for a more Intermediate WordPress implementor. Apart from needing to create a custom template PHP file to display the categories the way I want, if the user found a theme that has already created some useful templates then this process could easily be accomplished by more beginner level WordPress users.

Another option I could have used was Pages for each item as these can also have a parent to child structure. ┬áThe reason I did not use this option, is it made more sense to me to think of the multiple items as posts. Pages tend to lend themselves better as static items that don’t change often. With posts I can also very easily restructure the content by mass selecting various posts and creating new categories to place them in. Of course this will affect SEO so you will want to be sure the restructure is somehow accounted for by creating redirects or a useful 404 page.

The Requirements

There will be a section on the site for all of the Board’s content and the url should be similar to example.com/board . At this location the idea is to allow the posts to be displayed in chronological order with the most recent at the top. This root category will be called “Board” with the slug as “board”. Underneath the Board category will be “Minutes” with a slug of “minutes” and “Officer” with a slug of “officer”.

So as an example, I want to create an officer Jane Doe. The url structure should be example.com/board/officer/jane-doe. If i have the minutes for a board meeting in February 2017 the url structure should be example.com/board/minutes/february-2017

Setup

First, we need to adjust the permalinks structure to handle our categories. Go to your dashboard and under “Settings” / “Permalinks” select the “Custom Structure” option and add the following structure:

/%category%/%postname%/

make sure you start and end the structure with the slash ‘/’ and make sure a slash also separates each field name.

As an aside, I was playing around with how to create an archive template to display the second or deeper level categories and keep the url structure intact. This is not directly possible using the categories option without getting into a more advanced URL rewrite function added to your functions.php file. The idea I wanted was to be able to go to example.com/board/minutes and display only the posts related to minutes. This worked when I added to the Permalinks structure an additional %category% field like:

/%category%/%category%/%postname/

however, when i visited an actual minutes post the URL structure was example.com/board/minutes/board/minutes/february-2017. I did not want my structure for an actual post to double up the path, so as a work-around I put the Permalink structure back to a single %category% field and added a post at the top level structure of “Board” called “minutes”. The idea is that later as a more advanced level I would add code to the category-board.php file to check if the postname is “minutes” and filter the query so as to not display all Board posts, but to limit them to only Minutes. Not ideal, and probably can be done better if I used a Custom Post Type. I just wanted to see if I could try to keep this process as easy as can be for a more intermediate level WordPress user. I will not be going to show this level of extra code for now and just ignore the requirement to have a working example.com/board/minutes URL.

Customize Display

You can stop there if you like how your current theme displays the categories. However, for my purpose I wanted to have the information for each be a little more customized. I started by first copying the archive.php file in my theme and saving as category-slug.php for each level category. For example:

category-board.php

category-minutes.php

category-officers.php

And then edited the files to the specifics of how I wanted to display each. For the Board category I plan to use Bootstrap’s card component to visually enhance the excerpt from each post.

[Note: sorry I have not completed this post as of 2/26/2017. I am currently testing how this works. I will post samples of the code as I go along. The above material is what I know as of today. I plan to finish this post as soon as I can as I want to use this as my speaking topic at the next local WordCamp this year (my motivation for this topic)]