I’ve wanted to learn how to do this for ages, and today I got the chance.
This simple WordPress shortcode will find all of the children of the current post and spit out an
<ul> of them with titles and links. The shortcode has two optional parameters:
removewill be passed to
str_replaceon each post title and replaced with a space (e.g.,
str_replace($remove, '', $post_title);).
excludeis a comma-delimited string that, when exploded, creates a set of items that, if matched, will result in the containing element being ignored.
In reality, the shortcode looks like this:
[foo_generate_inline_menu remove="blarg" exclude="butts"]
Here’s the code.