The following shortcode is designed to list all pages that are immediate children of the current page. You may include just the title or the title with an excerpt and/or thumbnail of the child page.
Below is a list of all parameters with some examples of their use.
‘post_type’ => ‘page’
This setting is optional. page may be substituted for any archival post type. For example if you created a custom post type called Favorite Artists with a slug of favorite-artists then that would go there.
Note: This is completely optional since the plugin is setup now to automatically detect the current post type and if it is set up to have children that is with sub-pages it should work. If for some reason it doesn’t put the custom post type slug here.
If for some reason you only want selected child pages to show enter their post_id here. Comma separated list.
Same as above but will exclude specific child pages.
These two work together. The default posts per page is three but if you would like to have a paginated list of your child pages (like there are many of them) then you may enter code as such.
[child-page-list posts_per_page='10' paginate='true']
will break the child pages in to 10 per page with pagination links.
Default setting above. May be ordered by numeric order which goes by post_id number. The three options are:
You may add asc or desc to the above parameters so they may reverse the order.
order_by=’title asc’ will show from Z to A instead of A to Z.
If you would like to include the pages featured image.
Choose the exact thumbnail size. Defaults are:
Plus any other custom post thumbnail size. An example shortcode would be
[child-page-list show_thumbnail='true' thumbnail-size='medium_large']
Read more about thumbnails at the WordPress Post Thumbnails Codex Page.
When set to true will show the manual excerpt field.
When set to true will show the pages (or custom post type ) content.
When set to true will show link text read more… at the end of the excerpt or content. Whichever is chosen.
You may change the text of the read more link to anything you like. For example read_more_text=’Continue reading…’.
‘title_length_words’ => false
If you would like to shorten the length of the titles, content or excerpt you may do so here. For example you don’t like your titles to wrap on to more than one line. The length_characters will do exact characters and the length_words will do the same but by whole words.
If you would like to use a custom title instead of the actual page title you may create a custom field text field and put the title here (including raw code).
If you would like the links to open in a new window you would put link_target=’_blank’
Works with the post-reviews plugin and if you would like to show the child pages star ratings then just change this parameter to ture.
Ignore this parameter and leave it at its default setting.
If you would like to wrap the shortcode in an ID then just select whichever one you would like. For example
If you would like to use your own custom title per page using the include_acf parameter above then you would set this to true. Works also if you only want to show images.
So it won’t show the name of the acf field put all field names here in a comma separated list.
This link will show an example of a typical parent page listing its child pages. It is using the manual excerpt field for the content. First the shortcode used then the link.
[child-page-list posts_per_page='12' show_thumbnail='true' shortcode_id='inline_layout' show_excerpt='true' paginate='true' use_layout='inline' include_link_title='true']
Example number 2. Below is the shortcode then the link to the page example.
[child-page-list order_by='numeric_order' shortcode_id='amsoil_warehouses' include_acf='custom_title' hide_acf_field_label='true' hide_title='true' posts_per_page='16']
Note in the image I wrapped the title in <a></a> so the title will be clickable.
The design of the layouts were handled using custom css which I will give examples in another tutorial.