mycred_users_of_rank shortcode." />mycred_users_of_rank shortcode." />

mycred_users_of_rank

Codex / mycred/rank / Filters / mycred_users_of_rank

Navigation:

  1. Description
  2. Used By
  3. Parameters
  4. Examples

Description

This filter allows you to filter the row template for the mycred_users_of_rank shortcode. If you find yourself using the same row template over and over again, this filter could adjust it for you automatically.

Requires myCRED 1.1 and Ranks Add-on to be enabled.

 

Used By

 

Parameters

  • template (string)
    Either the default shortcode template or the custom template.
  • atts (array)
    The shortcode attributes.
  • mycred (object)
    The myCRED Settings Object.

 

Examples

Example 1: If the shortcode attribute ‘wrap’ is set to ‘ul’, replace the given template with our own custom template.

add_filter( 'mycred_users_of_rank', 'customize_shortcode_template', 10, 3 );
function customize_shortcode_template( $template, $atts, $mycred )
{
	if ( $atts['wrap'] == 'ul' ) {
		return '<li>%rank_logo%<h1>%rank%</h1></li>';
	}
	return $template;
}

Example 2: Add support for post related template tags.

add_filter( 'mycred_users_of_rank', 'customize_shortcode_template', 10, 3 );
function customize_shortcode_template( $template, $atts, $mycred )
{
	$post_id = $GLOBALS['post']->ID;
	$template = $mycred->template_tags_post( $template, $post_id );
	return $template;
}

Last edited June 26, 2016