What Are Subpages and Why Would I Use Them?

WordPress has a built-in subpage feature allowing you to organize pages in a parent-child-sibling tree, and place them on the menu.

That begs a couple questions… Why would I use subpages? What plugins are available to assist and enhance them?

That’s exactly what we’ll be addressing in this article.

Continue reading, or jump ahead using these links:

Why Use Subpages?
Creating Subpages and Adding to the Main Menu
Using a Widget to Place a Subpage Menu in a Sidebar
Using a Plugin for Improved Navigation on Each Subpage
Wrapping Up

Why Use Subpages?

The best use of subpages is to organize hierarchical content into a hierarchy or outline.

The subpage feature should not be used to paginate a long page. If you didn’t already know, James thinks Pagination Is Evil, and that’s not what I’m talking about.

If you simply have a long page, use the nextpage tag, which paginates a long page or post.

We can already do this simply by using the HTML heading tags (h1, h2, h3, etc.) as is done in most items posted here at WPMUDEV.com, and in this post. But subpages add the additional abilities to place them on the menu, in a sidebar menu, and provide navigation between them.

Creating Subpages and Adding to the Main Menu

Before we can use any of the advanced subpage features, let’s see how to create subpages.

When adding or editing a page, in the right hand-column under the heading Page Attributes, select Parent for the page, making the page we’re working on a subpage or “child” of “CV”.

The other “Exhibition” pages listed under are parent (“CV”) are also subpages, and are the “siblings” of the “Celine Raphel-Leygues” page.

Once a subpage has been created, it can be added to the menu by hand. Or better yet, by using a plugin to Automatically Add WordPress Submenu to Parent Menu for Pages, giving this result:

Subpages in the main menu dropdown.

Using a Widget to Place a Subpage Menu in a Sidebar

In the following example, I first used the Subpages Extended plugin to create a subpage menu in the sidebar.

Subpages Extended plugin in the Page editor.

Then I used the Custom Sidebars plugin to display this menu on the parent page and its subpages only.

Subpage menu in sidebar created with the Subpages Extended and Custom Sidebars plugins.

The Subpages Extended plugin creates a subpages navigation (table of contents) on your pages and your sidebar.

The widget option is so easy to use, and the shortcode option gives you more control for manipulating your subpages menus.

Here is the basic shortcode usage:

[subpages exceptme=”true” childof=”253″]

The Custom Sidebars plugin is a flexible widget area manager that allows you to replace sidebars—and other widget areas—on your site. (Custom Sidebars works with the classic widgets screen that was used in WordPress before version 5.8. To use it with version 5.8 and above, you’ll need to install the official Classic Widgets plugin).

Using a Plugin for Improved Navigation on Each Subpage

When using the nextpage WordPress tag, the navigation inserted at the bottom of each paginated page simply lists the paginated pages as numbers (i.e., 1, 2, 3, 4) with each page number linked appropriately.

This works fine for breaking up a long page, but not when we want to organize the information into subpages to gain the benefits of the subpage feature and plugins. (See Pagination: How to Split a WordPress Post into Multiple Pages tutorial.)

I used the List Pages Shortcodes plugin to place navigation at the top of each subpage and the parent page.

Here’s what it looks like on one of the subpages:

Subpage navigation on subpage using the List Pages Shortcodes plugin.

This is the shortcode I used:

[sibling-pages exclude=»150″]

I chose to exclude a link to the subpage currently being displayed from these links. In this example “Exhibitions 2020–2022” is pageid 150, and is excluded in the shortcode.

One other plugin I made use of was Catch Ids—making it easier to determine the pageid’s for my parent page and subpages.

Though some of these plugins are a year or more out from updates, we tested them (during the 2022 rewrite of this post), and they still worked as expected.

Wrapping Up

So there you have it. A neat and tidy way to implement subpages and widgets, using a few handy plugins, and a bit of shortcode.

Editor’s Note: This post has been updated for accuracy and relevancy.
[Originally Published: September 2013 / Revised: April 2022]

Щелкните ниже, чтобы поставить оценку!
Всего: 0 В среднем: 0

Написать комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *