List child pages aside the parent page
Have you ever wished to be able show child pages belonging to the actual displayed page?
One way of doing it, is mention the pages in parent content it self.
This is the worst idea how to solve this problem ever. It is not flexible, you have to add new link over and over again, not speaking of the link consistency, the design and everything you can think of.
Another solution can be the custom menu, ideally enhanced by some of the auto page populating plugin so you do not have to add each child page by hand. Well this is much better solution then the first one but still not ideal. You have to make that menu for each parent page and so it is far from perfect.
The solution I will show you now is much smoother, you do it once and it does its job everytime when it makes sense to do so.
We will not only solve this task but you’ll be able to expand it way further, add featured images for each child page, show the excerpt and everything programmatically not even touching the code.
All you need is the Easy plugin indeed.
Once you have the plugin installed and ready go to the Widget area under the Appearance>Widgets drag the easy to the sidebar you want the child pages to be shown.
For those who are not familiar with the Easy plugin:
Easy has basically three parts, first on top is a General section where you set your widget name etc. Second is the View. It consists of many bricks representing, title, comments, images, content etc. The third part is the Control area on the bottom right side. There you find many bricks. Control bricks like number of post you want to see, category filter, hierarchical filter and so on. The hierarchical brick will be the one who is the key thing for us in this case.
Drag the Title brick from the View “container” down to its slot. and then drag the the Hierarchy based brick from the Control container bellow and the Number brick as well.
Here comes the most important trick of this tutorial! Right in the first select box in the Hierarchy based brick select the Child pages of current page. This option will say to Easy to find all the children pages of the actual page and displays for them what you have set up in the View slot :)
Can you guess hot to display the featured image for each of these child pages?.. well later, wait.
The Number brick is there just because we have to tell it how many pages we want to see. By default the number is set to 1. So if you do not want to be restricted by “any” number, write there something like 100 for example… If you do not have 100 child pages it will show what you got not more.
That’s the work is done :) sweet, easy :)
Save the widget and check what you have just set up.
If any such structure exists, like having page parent with bunch of child pages, you have to see names of the child pages when viewing the content of the page parent. …hmm but we want the names to be links right? Go back, and in the Title brick change in the first select box the “no link” option to “link to post” ..save the widget and whoala .) the names are proper links to your child pages as you have expected.
If you still have not enough and want to see the featured image along the title and the content, or the excerpt or who know what, just drag more bricks from the View Container down to the slot and play as you like. It’s easy and most of the time self explaining.
note: If you see the top most page in your hierarchical structure then you should see pages from the topmost level. They do not have any parent, remember they are it the top level , and so you’ll see the first level pages as a descendants of a void.