Do you want to display all of your child pages on the parent page itself? If so, have you considered creating an index for child pages? Parent and child pages are similar to categories and subcategories. A parent page and category are a broader topic, while a child page and subcategory are a specific topic from that broader topic.
For example, a parent page may be about pets, while child pages may include dogs, cats, fish, and birds. Breaking up larger pages into multiple child pages is a good way to avoid cluttered and busy pages. Keep in mind that need to set up parent and child pages before beginning. Today, I will demonstrate how to create a child page index for parent pages in WordPress.
Why Add An Index of Child Pages on a Parent Page
A common mistake that many beginners make is creating pages that have too much content. This generally makes that page too busy and can even feel cluttered at times. A better technique is to take these larger pages (parent pages) and make different topics out of them on smaller pages (child pages). This, of course, creates a new problem, how will the visitor know that they are related?
In some cases, a very large page can be broken down into multiple parent pages with their own child pages. It is important to keep relevant content together. This is where an index system of child pages will help the parent page. In our pet page example, it is very easy to understand that everyone does not like the same kind of pets. Creating an index allows visitors to click on the child pages that are most relevant to them.
How to Create a Child Page Index For a Parent Page in WordPress
Today, I will demonstrate how to create a child page index for parent pages in WordPress. You will not need any additional plugins for this task. You will need access to your website’s cPanel, which is provided to you by your web host when you create an account. Since you will be directly editing code, I would recommend creating a backup of your website. This will ensure that you can revert your website back to before you began, in case a mistake is made. I will first demonstrate how to create parent and child pages.
How to Create Parent and Child Pages
Creating a parent and child page is very easy. Parent pages are not made to be parent pages. Instead, you select pages that are related to the parent page and call them child pages. For example, I created three pages Pets, Dogs, and Cats. Pets will be the parent page, but I did not tell WordPress that.
Go to any page that you would like to make a child page. In my case, I am choosing the Dogs page. On the right-hand side of the page, you will see a Page Attribute box. Under the word “Parent” you will see a drop-down box. Select the page you would like to be the parent page. In my case, I am selecting the Pets page.
By doing this the page you selected will be the parent page of the child page you are on. Save your work. When you are selecting pages you will be able to tell what pages are parent and child pages. This can be seen by the child pages being dashed beneath the parent page like so.
How to Add an Index to Parent Pages
Now that you have your parent and child pages set up, it is time to add the index. This will help visitors locate relevant pages with ease.
Let’s start by logging into the cPanel and clicking on the File Manager option. The File Manager will allow you to access all of the files related to your website.
You need to locate your themes functions.php file. Click on the public_html directory, then click on the wp-content folder. Inside of this folder, you will find all of the content related to your website. Click on the themes folder and enter the folder of the theme you are currently using. Finally, right-click on the functions.php file and select the Edit option.
A pop-up window will show up. This box will warn you to create a backup of your files before editing anything. This will ensure that you can revert your website back to when it was working if something goes wrong. Click on the “Edit” button. A new tab will open containing all of the code from the file.
Copy and paste the following code into your themes functions.php file:
This code will simply check to see if the page is a parent page. If it is a parent page, it will display the child pages and if not, nothing will happen. This is done by using the shortcode [index_childpages].
Once you have inserted the code into the functions.php file, click on the “Save Changes” button to finish.
Now, visit any page that is a parent page and insert the shortcode where you would like it placed. Alternatively, you can use the shortcode in a text widget and get it to appear on the sidebar.
You can now view an index of all of your child pages for a parent page.
Congratulations, you have successfully learned how to create an index of all of the child pages for a specific parent page. Remember that you will have to paste this shortcode on every parent page if you want it inside of the page. If you post it on the sidebar it will display correctly for each page.
Keep Relevant Content Grouped Together
One of the most annoying things that a visitor will encounter is not being able to find relevant content. This will make the visitor go through multiple pages that are not related to what they are looking for. No one likes to navigate menus or click on the wrong link by mistake. Make it very clear and group up relevant content by using parent and child pages.
Remember that parent and child pages are very similar to categories and subcategories. Using these is another effective way to solve the problem. Categories and subcategories also have the advantage of helping your website’s SEO. Since SEO directly affects the amount of traffic from search engines like Google and Bing, it is important to improve it.
How many parent pages do you have on your website? How many child pages does each parent page have?
Author: Chris Racicot
Chris is the Support Manager at GreenGeeks and has been with the company since 2010. He has a passion for gaming, scripting and WordPress. When he’s not enjoying his sleep, he’s working on his guitar skills and fiddling with 3d printing.