Documentation – mockingbird()

This function will output and render a list of related posts. To return related posts as data, use the get_mockingbird() function instead.

Usage

mockingbird( $id, $custom_styles, $key );

Parameters

$id (integer) (optional)
The ID of the post from which you want to return data. Use the get_the_id() function while in the loop to get the post’s ID, or use your sub-loop’s post object ID property (eg $my_post_object->ID). You may also use the global $post object ID (eg $post->ID).

Default: none

$custom_styles (array) (optional)
An array of specified styling parameters when the displayed listed is rendered. This provides a framework for styling list results, however this may prove restrictive for advanced development. It might be more appropriate to output the list manually using the get_mockingbird() function. The styling options are:

  • wrapper – html tag to use as the list container. Defaults to “<ul>”.
  • before – html before the item, typically an opening tag. Defaults to “<li>”.
  • after – html after the item, typically a closing tag. Defaults to “</li>”.
  • before_title – html before the item title, typically an opening tag. Defaults to “<h2>”.
  • after_title – html after the item title, typically a closing tag. Defaults to “</h2>”.
  • title – title for the list container. Defaults to “Related Content”.
  • include_thumbnail – whether to display post thumbnails. Defaults to false.
  • include_excerpt – whether to display post excerpts. Defaults to false.
  • excerpt_length – Length (in characters) of the displayed excerpt text. Defaults to 100.
  • excerpt_link_text – call to action link displayed after excerpts. Defaults to “Read More”.

Default: false

$key (string) (optional)
A string value to specify the meta key used to retrieve saved mockingbird data. If additional Mockingbird instances have been created, a unique key is required to distinguish it from other instances. Aimed at advanced development, its unlikely that you will need to deviate from the default key during standard development.

Default: ‘sc_mockingbird’

Examples

Print the related list for the post with an id of 5.

<?php mockingbird( 5 ); ?>

Print the related list for the current post and apply a custom class attribute to each item’s heading.

<?php
	$styles= array(
		'before_title' => '<h2 class="related-posts">',
		'after_title' => '</h2>'
		);

	mockingbird( get_the_id(), $styles );
?>

Print the related list for the current post using a custom Mockingbird key.

<?php mockingbird( get_the_id(), array(), 'my_testimonials' ); ?>