Many of us might remember when news and articles were dominantly available on paper sources such as newspapers or magazines. These bunches of paper were (and are) usually organized into issues and volumes. For example, the New York Times on November 23, 1963 was Issue No. 38,654 in Volume CXIII (113). The days of periodical publishing, when every certain period of time, a collection of articles would be released, seem to have passed.
Nowadays, online news sources use “firehose” publishing, which douses readers in jets of information. They publish article, after article, after article. For many readers, especially readers more used to the old-time periodical publishing system, this can be extremely overwhelming. It may be time for periodical publishing to take a place online, taking the massive jumble of news and information constantly being posted to the internet and organizing it into easier to read periodicals.
As a WordPress user, someone who most likely has a blog, you may want to switch from WordPress’s “firehose” system to the better looking and working to an issues-based system. Not only will you be making it easier for users to read your articles, making them not feel pressured to be checking constantly and giving them a curated collection of your articles released on a stable, steady schedule, but you will also be relaxing your workload, ridding yourself of the burden of instant publishing.
A Simple Guideline
We’re going to be keeping it simple. Let’s make this easy to understand and implement and as compatible as possible.
Let’s also establish what exactly periodical publishing is:
- content is collected into issues
- only the content of the specific issue is displayed
- visitors can go to a back issues page and select a different article to read
- visitors can view the contents of each issue
- visitors can perform a search on a specific issue or the entire site
The only extension to the current content model we’ll be doing is a custom taxonomy (a custom way to group things together) called Issues, otherwise it uses categories, pages, and posts, just like most other WordPress sites.
A Quick Overview of What We’re Going to Do
Most of the work is going to be done by a custom taxonomy. There will be a few other components just to tidy things up.
- The custom taxonomy will collect posts into issues and provide automatic filtering if the taxonomy and a value is provided. As such, we need to make sure that the current issue is added to relevant links within the site.
- The homepage will need a little extra work as there won’t be an issue contained in the link. We’re going to filter the posts based on a custom global option we’ll create to hold the current issue value.
- To make sure we don’t navigate out of the current issue we need to add a check to post navigation to ensure that it only links to posts in the same issue.
- We need to update the custom global option when we want to publish a new issue. To do this, we’ll nominate a post category as the “master category” and whenever a new post is published in this category we’ll update the global option with the post’s issue.
- To make publishing an issue easier, when the post in the master category is published, we’ll also publish all other posts in the same issue and have a status of “pending”. Not having to publish all the posts before the master category keeps them from appearing in the search and keeps draft posts from being published.
- We’ll add the ability to set the master category and override the current issue by adding fields to the Settings > General page in the admin interface.
- Finally, we’ll make a few shortcodes. One will display the contents of the current issue – a list of the issue’s posts grouped by their category; the other will provide a list of “back issues” – a formatted list of published posts from the master category.
We’re going to set up, play with, and get a feel for the code instead of diving right into it. We’ll then step through how to do all this.
How to Set Up Periodical Publishing (A.K.A. How to Do this Quickly Without Learning the Code and System)
Setting up periodical publishing only takes 4 steps:
1. Download and Install the Plugin
All the code is available in a plugin here. Simply download and install the plugin into a site with enough content to make a few issues.
2. Create and Assign Issues
There should be a new menu option named Issues under the Posts menu. You can create new Issues and give them a description here. Add a description as you may want to use it in your theme.
Then go through existing posts (or make new posts) and assign issues using the Issue metabox in the right-hand margin.
3. Set the Master Category
In the admin interface, go to Settings > General and go to the section named Magazine Settings. Here you can set the master category and the current issue.
Posts in the master category make up an issue. When you publish a post in this category, it updates the current issue value with the post’s issue and publishes all other posts in the same issue that have the status “pending”.
The master category is also used by the [backissues] shortcode.
You can also set the current issue. This should be a drop-down box with the Issues you created in the second step. When you implement periodical publishing on an existing site, you’ll probably want to manually set the current issue.
4. Create the Back Issues and Contents Pages
Create two new pages for Back Issues and Contents, including the [backissues] and [contents] shortcodes as appropriate in the page body.
Add the new pages to a menu on your site.
This should be enough to turn your site in an issues-based magazine. Your site’s homepage should now only contain posts that are in the current issue.
Rolling over any category link should show you that “issue” has been appended to the querystring, ensuring that issue is carried across to archive listings. Individual post links don’t need the amended querystring as the current issue can be determined from the post itself.
Clicking around the site should show you that you remain in the current issue unless you do a search or select a back issue. Selecting a post from a search brings you to that issue.
If your site uses post navigation (previous post and next post) you’ll see that this also remains within the issue. This is due to the filter on the post navigation which will delete any link to a post outside the current issue.
You can also try publishing a new post in the master category. Make sure to have s0me posts in the same issue set to “pending” before your publish and you’ll see that all the posts get set to published and the global current issue option is updated.
How It Works
There’s a few components, but the main component is the custom taxonomy.
The Custom Issues Taxonomy
The custom Issues taxonomy allows posts to be assigned to specific issues, allowing control over when and how they’re displayed.
Custom taxonomies can be created using code or plugins. (One of which is WPMUDev’s custom type, custom field, and custom taxonomy plugin, CustomPress)
The plugin creates a new taxonomy which adds:
- a new Issues menu option under Posts in the admin interface where the Issues taxonomy can be managed
- an Issues metabox to the post edit screen where Issues taxonomy terms can be assigned to posts like tags
- an Issues column to the post listing screen allowing for the list of posts to be filtered by issue.
The most important part of creating the taxonomy is setting the query_var argument to true. This assignment provides the automatic filtering of posts if the taxonomy term and a value are included in the URL.
For example, with the URL magazine.com?issue=two, WordPress will recognize that a taxonomy (issue) is being used and will use the term (two) when querying posts, only selecting those posts that have been assigned the specified term.
This works great with periodical publishing and the filtering only happens in The Loop, meaning it doesn’t have any impact on menu or widget output.
That does, however, mean that we need to add the taxonomy to relevant links in the site.
NOTE: Remember to place the following code in a plugin!
Adding Issue to Page and Category Links
All we need to do is add the issue argument to page and category links. We don’t need to worry about posts, because we don’t need to filter them and we can pick up the current issue from the post itself.
To amend the querystring, we hook into the built-in filters that are activated when generating page and category links and add issue to the query arguments.[pbcode id=”qDZXEKEs”/]
The mag_get_current_issue() function determines the most appropriate term for the Issue taxonomy. It does this in this order of preference:
- If a post is being displayed, then get the term that is assigned to the post
- If the query_string contains issue, then use the value
- Get the value of the global option “current_issue”
The Home Page
If the visitor navigates to your site’s home page, then there’s no issue information for the page to work with. To help out the home page, we manually filter the post selection by hooking into the pre_get_posts action that gets called before a posts query is executed.[pbcode id=”5M2CBK5j”/]
This action gets called for every post query so the most important aspect is to make sure that only the main query on the home page is affected. We still check to see if issue is in the query string (if it is, then filtering will happen anyways) and if it isn’t, we set up our own taxonomy filter by adding a tax_query argument to the query.
Keeping Post Navigation on Issue
The post navigation links are not generated within The Loop, so the next and previous links aren’t filtered. If we left this alone, eventually links to posts outside the issue would appear.
We can prevent this by using the next_post_link and previous_post_link filters to only return a link if the post being linked to is in the current issue.[pbcode id=”PXBZQD9E”/]
Publishing an Issue
The master category controls the publishing of an issue.
The master category will serve as the “Editorial”. When a new post in the master category is published, it will publish all other posts in the same issue that have a pending status.
This is done by hooking into the publish_post action.[pbcode id=”Mh7u7HHY”/]
The function, called after the post is published, first checks to see if this is a first-time publish or an update. This code will only run on a first-time publish in the master category.
If the code continues, then we’ll first update the global current issue option with the issue assigned to the post. The first issue is always used, so if multiple issues have been assigned the others will be ignored.
We then get a list of the posts in the new current issue and set the publishing status to publish. When setting up the argument for the call to get_posts, posts_per_page is set to -1 to override any built-in limit. Also, before looping through the posts, the custom action is removed. This is to stop the custom function from getting called as a result of the call to wp_update_post and helps prevent endless loops.
The action is restored after all posts have been processed.
Making Things Easier with Shortcodes
The plugin includes three shortcodes:
- [backissues] displays all the posts from the master category in an unordered list
- [contents] displays posts for the current issue within unordered lists within an unordered list of category headings
- [display_issue] displays a <div> containing the current issue term and the issue description
The plugin enables shortcodes to be used in widgets.
This is a good basic framework for a issues-based blog, but you may want to consider extending it. Some good ideas may be to refine the search function, making a cover for the issue, etc.
After making the above code into a plugin or just downloading the pre-made plugin, you should be set up as an issues-based site. Enjoy!