When you publish a page in WordPress, you have the option of selecting a parent page. All pages underneath that page become child pages - essentially creating a subset of pages (attached to a topic). The WordPress shortcode and plugin as described in this article will permit you to render all page results attached to a parent page in a list. See examples on our code page and reference page. While we've provided a few of these types of shortcode in the past, they'll all be rewritten so the code is a little closer to WordPress best practice.
As linked to above, the shortcode will list pages attached to a parent page (or a page as defined in your shortcode). As an example, the shortcode of
[childpages page="12345" description="false"] will return the list as rendered below (where '
12345' is your parent page). If the
page attribute is not used, the current page will be used as the parent page. I've used
description="0" to prevent the excerpt from printing.
The following shortcode attributes may be used. We'll add more options in the future so make sure you subscribe to us on Facebook for updates.
12345is that page ID.
removeattribute is used to remove a string of text to be omitted from your excerpt. In our case, we use it to remove the tweet text and Facebook that's rendered by default with our post. So, we use
remove="Tweet and like us on FB ".
wordsattribute relates to the number of words in your excerpt. To limit your excerpt to 20 words, use
exclude="20,21,22,23"(a comma-delimited list of page IDs to be left out).
Copy and paste the WordPress function into your theme's
functions.php file or, if you sensibly have one installed, your custom functions plugin.
- Read more on wp_query here .
- We'll likely develop this into a more robust plugin with pagination and other features. So, the plugin option isn't entirely unreasonable (we'll let you know when the update is available).