Knowledge Base v2.1.0 added support for displaying related articles at the bottom of the articles page. This is enabled by default and can be turned off by unchecking Show related articles in the Output tab in the settings page.

Related Articles are only displayed when using the default templates. If you’re using your own template, you can add the related articles using the template function wzkb_related_articles().

wzkb_related_articles( $args = array() )

This function displays the related knowledge base articles from the same sections (categories) or tags.

Parameters

It accepts the following parameters as an array.

  • ‘numberposts’
    (int) Total number of posts to retrieve. Is an alias of $posts_per_page in WP_Query. Accepts -1 for all. Default 5.
  • ‘echo’
    (bool) Echo or return?
  • ‘post’
    (WP_Post) Post ID or WP_Post object. Default current post.
  • ‘exclude’
    (string|int[]) Post IDs to exclude. Can be in CSV format or an array.
  • ‘show_thumb’
    (bool) Show thumbnail?
  • ‘show_date’
    (bool) Show date?
  • ‘title’
    (string) Title of the related articles. Default is Related Articles wrapped in an H3 header tag.
  • ‘thumb_size’
    (string) Thumbnail size.

Customising the output

The default view of the related articles is below. It is fully responsive and uses CSS Grid to display the output. You can use your custom CSS either adding it in the Styles tab or in your styles.css to modify the output.

Currently, the related articles doesn’t have any settings that can be customised via the Settings page. However, you can override the main parameters that are passed to wzkb_related_articles() by using the filter function wzkb_related_articles_args which accepts the arguments as an array.

The below example will display 10 related posts.

function filter_wzkb_related_articles_args( $args, $id ) {
	$args['numberposts'] = 10;
	return $args;
}
add_filter( 'wzkb_related_articles_args', 'filter_wzkb_related_articles_args', 10, 2 );