Classifying posts by Category or Tag is sometimes not enough for you. You may need to use another way to create a series of posts. It will help readers to follow the series more easily. In this article, I will show you how to create a post series in a new way using the Meta Box plugin.

You absolutely can create a series for posts by Category or Tag. But this way has a few drawbacks as follows:

  • In some cases, you may need to create a large number of posts series. If you use categories, creating too many categories will make the posts structure and classification bulky and intricate;
  • If you set up the post permalink to include the category name, your links will be longer and more complicated with many types of links;
  • Category displays in an order which is from the most recent posts to older ones. However, most users need to read from the first post of the series. They’re going to have to scroll down to the bottom to find it. Using series will help you to reverse the post's order from the first to the last. It makes it easy to find posts.

For those reasons, I decided to create the post series in a different way. Using the Meta Box plugin help me to manipulate easily by creating a new taxonomy.

Now, let's see how we do it.

Before Getting Started

You need to install and activate the following two plugins on your WordPress website:

  • Meta Box plugin
  • MB Custom Taxonomy: is a free extension of the Meta Box plugin but requires separate installation. This plugin allows you to create and manage custom taxonomy with an intuitive interface. If you don't want to install a plugin, use this Taxonomy Generator online tool (free).

Both plugins are free. You can download and install them directly from the admin dashboard.

Install Meta Box and MB Custom Taxonomy plugins directly from the admin area
Install Meta Box and MB Custom Taxonomy plugins directly from the admin area

Step 1: Create a New Custom Taxonomy

As mentioned above, I'm going to create a new custom taxonomy so as to serve the creation of post series in which uses the above two MetaBox plugins.

First, in the admin dashboard, go to the menu Meta Box > Taxonomies > Add New.

Create a new Custom Taxonomy

In the edit page of taxonomy, you enter the basic information as follows:

Enter information for Taxonomy
Enter information for Taxonomy

In the Assign To Post Types section, select the post types of the posts that you want to set the series. In this example, I choose Post (i.e the default blog posts).

Remember to save this taxonomy and check it on the post-editing page. At this point, you will see an additional item named Series as shown below:

The Series section appears in the post-editing section
The Series section appears in the post-editing section

Now, if you want the post to belong of any series, just enter that series name. You can create a new series or choose an available one right here.

Step 2: Display Posts in the Series in the Frontend

For example, metabox.io has a post series about Custom Fields like this:

Display posts in series in the frontend

There are two parts on this page:

  1. Briefly display the list of articles with only their titles
  2. Display posts one by one with their titles, photos, and descriptions

All posts are displayed from the oldest to the newest. To do it, I manipulate one by one as follows:

Style the Page Displaying the Series

Create a file named taxonomy-{taxonomy}.php in your theme folder. In which, {taxonomy} is the slug of custom taxonomy that you have created above. Accordingly, my file will be named taxonomy-series.php.

Create a file in the theme folder
Create a file in the theme folder

This file will be used to specify how the series displays on the frontend. If you do the above, the page interface will display the following when you go to the list of posts in a certain series:

Style the page displaying the series

Next, copy the content of the archive.php file in the same folder of your theme into the file that you have just created (the taxonomy-{taxonomy}.php file).

Copy content from Archive.php file
Copy content from Archive.php file

At the same time, add the following code to the taxonomy-{taxonomy}.php file.

if ( have_posts() ) :
    echo ‘<ul class="series-list">’;
    while ( have_posts() ) : the_post();
        echo '<li><a href="'.get_the_permalink().'">'.get_the_title().'</a></li>';
    endwhile;
    echo ‘</ul>’;
endif;
Add code to the taxonomy file
Add code to the taxonomy file

Now, your series has displayed the style of the theme, but with the wrong order (the first posts first, the old posts display later). So next, you need to reverse this order.

The post series is displayed in the wrong order
The post series is displayed in the wrong order

Reverse the Order of Posts in the Series

Add the following code to the functions.php file in the theme folder.

add_action( 'pre_get_posts', 'series_post_order');
function series_post_order($query){
    if(taxonomy_exists('series')):
        $query->set( 'order', 'ASC' );
        $query->set( 'orderby', 'date' );
    endif;
};

Remember to change the above series parameter to the name of the taxonomy that you have just created.

Reorder the posts
Reorder the posts

At last, your post series page will display as follows:

Reverse the order of posts in the series

Final Words

With the MB Taxonomy of Meta Box, creating a series for posts is quite simple, right? However, there are several other ways to create a series of posts that you can refer to. This way is given to make you understand more about the application of Meta Box when it comes to reality.

By the way, let’s read more about the series of posts about the application of Meta Box in specific cases in practice.

1 thought on “Create Posts Series in WordPress Using Meta Box

  1. How can I query mb_taxonomy from string? like `author_name=admin&category_name=uncategorized&posts_per_page=2` (to make a query for taxonomy meta from OxygenBuilder repeater.)

Leave a Reply

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