Page Hierarchy
Learn to set up a page hierarchy with parent and child pages.
Page hierarchy
Hierarchy helps in organizing the web pages in the website by grouping related items together. This adds structure to the website and makes navigating and finding content easy. Hierarchical post types have a parent and child relationship. A child page has one parent while a parent page can have multiple child pages.
Blog posts are non-hierarchical. There is no parent-child relationship in blog posts, but they can be organized using tags and categories. The difference between hierarchical and non hierarchical post types is that the former has a unique parent page while the latter can be grouped in numerous categories with the help of multiple tags.
Parent-child relationship
A parent page contains content that covers a broad concept and contains a group of related child pages. Child pages can have sibling pages that are on the same level in the hierarchy. To demonstrate this concept, we will create two child pages under the About Us page. One is called Vision and Mission and the other is called Our Story.
Go to the admin dashboard, choose "Pages" from the sidebar and click the "Add New" button.
The title of the page is Vision and Mission. We will paste some dummy text for the content. To set this page as a child page under the About Us page, we will set the page attribute from the sidebar on the right.
Here we can choose a parent page from a list of pages in our site. Choose "About Us" and publish the page.
Following the same steps, create another page called Our Story and make it a child page of the About Us page. Notice that we can see a hierarchy of pages, with "Vision and Mission" shown as a subpage of the "About Us" page in the drop-down menu.
This hierarchy is reflected in the URL of the page as well.
The slug of the About Us page is "/about-us".
The slug of Our Story page is "/about-us/our-story".
There is also an order option which can be used to manually set the order in which the pages appear in a menu.
Find if a page is a child page
Every post or page of the website has an ID ...