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

WordPress. How to display a list of child pages for a parent page
Linsey Sawyers

The above code first checks 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:

Be the first to comment

Leave a Reply

Your email address will not be published.