Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
25 Million+
Websites using our plugins
Years of WordPress experience
WordPress tutorials
by experts

How to Display a List of Child Pages For a Parent Page in WordPress

Editorial Note: We earn a commission from partner links on WPBeginner. Commissions do not affect our editors' opinions or evaluations. Learn more about Editorial Process.

Recently, one of our readers asked us how to display child pages of a WordPress page?

If you organize your WordPress website with parent and child pages, then you may want to display your child pages or sub pages on the main parent page. You may also want to show the main page on each sub page for easy browsing.

In this article, we will show you how to easily display a list of child pages for a parent page in WordPress.

Displaying a list of child pages for a parent page in WordPress

When You Need to Show a List of Child Pages?

WordPress comes with two default post types called posts and pages. Posts are blog content, and they’re usually organized with categories and tags.

Pages are one-off or standalone content that are evergreen, such as an ‘About us’ page or ‘Contact us’ page, for example.

In WordPress, pages can be hierarchical which means you can organize them with parent and child pages.

For instance, you may want to create a Product page with child pages for Features, Pricing, and Support.

To create a child page, follow our guide on how to create a child page in WordPress.

After you’ve created your parent and child pages, you may want to list child pages on the main parent page.

Now, an easy way to do this is by manually editing the parent page and add a list of links individually.

Manually add child page links

However, you’ll need to manually edit the parent page each time you add or delete a child page. Wouldn’t it be nicer if you could just create a child page and it would automatically appear as a link on the parent page?

That being said, let’s take a look at some other dynamic ways to quickly display a list of child pages on the parent page in WordPress. We’ll show you three methods, so you can pick the one that’s best for you:

Method 1. Display Child Pages on Parent Page using a Plugin

This method is easier and recommended for all users.

First, you need to install and activate the Page-list plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to edit the parent page and simply add the following shortcode where you want to display the list of child pages.


You can now save your page and preview it in a new browser tab. You’ll notice that it displays a simple bulleted list of all the child pages.

Plain list of child page links

If you want, you can add some custom CSS to change the appearance of the list. Here is some sample CSS you can use as a starting point. {
    list-style: none;
    list-style-type: none;
    background-color: #eee;
    border: 1px solid #CCC;
    padding: 20px;

After applying your custom CSS you can preview the parent page. This is how it looked on our test WordPress website.

Child pages list with CSS

The plugin provides a bunch of shortcode parameters that allow you to set depth, exclude pages, number of items, and more. For details, please see the plugin’s page for detailed documentation.

Method 2. List Child Pages for a Parent Page using Code

This method is a bit advanced and requires to you add code to your WordPress website. If you have not done this before, then please take a look at our guide on how to copy and paste code in WordPress.

To list child pages under a parent page, you need to add the following code in a code snippets plugin or in your theme’s functions.php file:

function wpb_list_child_pages() { 
global $post; 
if ( is_page() && $post->post_parent )
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
    $childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
if ( $childpages ) {
    $string = '<ul class="wpb_page_list">' . $childpages . '</ul>';
return $string;
add_shortcode('wpb_childpages', 'wpb_list_child_pages');

At WPBeginner, we always recommend adding code in WordPress with the WPCode plugin.

WPCode allows you to easily add custom code without editing your theme files, so you don’t have to worry about breaking your site.


First, you need to install and activate the free WPCode plugin. For step by step instructions, see this guide on how to install a WordPress plugin.

Once the plugin is activated, navigate to Code Snippets » Add Snippet from your WordPress dashboard. From there, hover your mouse over the ‘Add Your Custom Code (New Snippet)’ option and click the ‘Use snippet’ button.

Add a new custom code snippet in WPCode

Next, add a title for your snippet and paste the code from above into the ‘Code Preview’ box.

Don’t forget to choose ‘PHP Snippet’ as the code type from the dropdown menu on the right.

Paste code into WPCode plugin

After that, simply toggle the switch from ‘Inactive’ to ‘Active’ and click the ‘Save Snippet’ button at the top of the page.

Activate and save your custom code snippet

This code first checks to see if a page has a parent or the page itself is a parent.

If it is a parent page, then it displays the child pages associated with it. If it is a child page, then it displays all other child pages of its parent page.

Lastly, if this is just a page with no child or parent page, then the code will simply do nothing. In the last line of the code, we have added a shortcode, so you can easily display child pages without modifying your page templates.

To display child pages simply add the following shortcode in a page or text widget in the sidebar:


Don’t forget to save your changes and preview them in a browser tab. This is how it appears on our test site.

Plain link list

You can now style this page list using some custom CSS. Here is some sample CSS code you can use as a starting point.

ul.wpb_page_list {
    list-style: none;
    list-style-type: none;
    background-color: #eee;
    border: 1px solid #CCC;
    padding: 20px;

Method 3. Dynamically Display Child Pages Without Any Shortcode

Using shortcodes is convenient, but the problem with them is that you will have to add shortcodes in all pages that have parent or child pages.

You may end up having shortcodes in lots of pages, and sometimes you may even forget to add it.

A better approach would be to edit the page template file in your theme, so that it can automatically display child pages.

To do that, you need to edit the main page.php template, or create a custom page template in your theme.

You can edit your main theme, but those changes will disappear if you change or update your theme. That’s why it would be better if you create a child theme and then make your changes in the child theme.

In your page template file, you need to add this line of code where you want to display child pages.

<?php wpb_list_child_pages(); ?>

That’s all. Your theme will now automatically detect child pages and display them in a plain list.

You can customize the styles with CSS and formatting. Here’s an example of how the OptinMonster website shows the parent page and sub pages:

OptinMonster Sub Pages Example

We hope this article helped you list child pages for a parent page in WordPress. You may also want to see our guide on the most important pages to create on a new WordPress website, and our comparison of the best drag & drop WordPress page builders to create custom layouts without any code.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

81 CommentsLeave a Reply

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Philip says

    Hello this works, except that the parent is also displaying, how do i show just the child pages, thanks

    • WPBeginner Support says

      The simplest method for what it sounds like you’re wanting would be to not have content on the parent page and only have your content in the child pages.


  3. Emmanuel Husseni says

    Hello Wpbeginner,

    Please how can i sort all the child page alphabetically on the parent page. I’ve follow all step but the sub pages are showing randomly on the parent page.

    Waiting for response. ….Thanks

    • WPBeginner Support says

      You would change the two instances of menu_order in our code to be: post_title


  4. Aaro says

    Can I assign a css class to this function? So that when I make css changes to ul elements it wouldn’t affect other ul’s on the site.
    Or any other simple solution for this?

  5. Keshav Murthy says

    Hi, WPB Team,

    Thank you so much for this Snippet and the tutorial.

    It saved my ton of time and helped me too.

    With Warm Regards,
    Keshav Murthy

  6. Gary Granai says

    I installed the plugin code snippets in wordpress 4.9.8

    I copied the code on and added it to a new snippet in code snippets.

    I made a page and then a page which was given the attribute of having the first page as the parent page.

    The child parent relationship is shown in the list of pages in the attributes drop down.

    When I open the parent page I see nothing that shows a child page.

    I then tried using the functions.php page.

    I added the code copied from to the bottom of the code on the functions page.

    When I open the parent page, I it does not display. What displays is an error message saying there is unexpected code.

    I restored the functions.php page to its original statuc.

    What changes must I make to what I have tried to do.

    • WPBeginner Support says

      Hi Gary,

      Make sure that you publish the child page before testing the code. Also carefully copy the code again to make sure that you are not copying the numbers or any unexpected characters.


  7. Itika says

    I have a question. I have added sub pages in parent page but when I am opening the site in mobile and clicking on parent page it opens the empty parent page. To view the drop down sub pages one have to hold the button of parent page. How can I fix it. I don’t want that empty page to open. I want that if we touch on parent page it opens the drop down menu.
    Please suggest how to do it.

Leave a Reply to ethann Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.