ShortCode

[tws_children]

This ShortCode is part of the ToolWine ShortCodes Plugin. Download and Install the ToolWine ShortCodes Plugin to use it. Note that the Plugin requires Toolset Types and Views (or Blocks) installed and active.

The [tws_children] ShortCode can be used to get and display Child Posts of a particular page or post. This ShortCode refers to WordPress’ native Post Relationship which by default is implemented only for WordPress Pages, but this hierarchy can also be enabled on any other post type. In this case the ShortCode will also work with custom post types

The ShortCode can output the results of posts found in different output format (even comma separated list) and it can display different parts of the Post Data.

The real power here is, you can add custom shortcode attributes as long they correspond to the WordPress Post Query. Everything what you can pass to a `get_children()` call of WordPress you can pass to this ShortCode as a attribute=value pair.

Attributes:

  • outputstring [any valid Post Object property]
  • propstring [any valid Post Object property] only used when output is comma-list
  • post_parentint [post ID of which to get children of]
  • post_typestring [the post type if not pages]
  • custom – any valid get_children query argument as ShortCode attribute and value pair.

Example:

//Get the count of child posts to 322
[tws_children output="count" post_parent="322"]
//Get a comma separated lists of Post IDs child to 322, and then a comma separated list with Post Titles
[tws_children output="comma-list" prop="ID" post_parent="322"]
[tws_children output="comma-list" prop="post_title" post_parent="322"]
//Get only the first two child posts Post Dates of custom post type products, in a comma list
[tws_children output="comma-list" prop="post_date" post_parent="322" numberposts="2" post_type="product"]