Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:Bforchhammer/Author Avatars ShortCode Documentation

Note: this page is no longer maintained, please refer to this page instead.

This page explains how to use the shortcode tag in the Author Avatars List plugin.

The [authoravatars] shortcode

As of version 0.4 the plugin comes with a shortcode which can be used to show lists of avatars on a page or inside a post. It's simple: just add [authoravatars] into your post and hit save!

Available Parameters

Just as for the widget you can use various parameters to configure the list of users.

roles: Only show users of a certain role

Restrict the list of users by roles to show only users belonging to certain roles. Possible values in a default wordpress setup are: administrator, editor, author, contributor, subscriber. Separate multiple values by a comma.

Example: [authoravatars roles=administrator,editor]

hiddenusers: Remove users from the list

Hide one or multiple users from the list. Both login names and user ids are allowed as values. Separate multiple values by a comma.

Example: [authoravatars hiddenusers=admin]

avatar_size: The size of the avatar images

You can adjust the size of the avatar by specifying the avatar_size parameter.

Example: [authoravatars avatar_size=25]

link_to_authorpage: Disable the link to author pages (deprecated)

This is deprecated since version 0.7. Please use the user_link parameter instead.

By default user avatars are linked to their respective Author Page. If your theme doesn't support them or you don't want to show them e.g. for subscribers, then you can easily deactivate them by setting this paramater to false.

Example: [authoravatars link_to_authorpage=false]

user_link: Link user avatars to user website, blog or authorpage

As of version 0.7 you can link users not only to their respective Author Page but also their website if available or blog on WordPress MU sites.

Version 0.7.3 adds the option to link users to their respective BuddyPress Members page.

Allowed values: false, authorpage (default), website, blog (wpmu only), bp_memberpage (bb only)

Example: [authoravatars user_link=website]

show_name: Show user names next to avatars

If you'd like to show the user display names next to the avatars set the show_name parameter to true.

Example: [authoravatars show_name=true]

Note: you can choose to display the Username, Name or various other options by setting the "Display name publicly as" option on the Users/ Edit user page.

limit: The maximum number of avatars shown

Example: [authoravatars limit=3]

order: The order in which users are shown

Users are ordered by their display name A-Z by default. You can adjust this by changing this parameter. Possible values are: random, user_id, user_login, display_name, post_count (0.7+), date_registered (0.7+).

Example: [authoravatars order=random]

sort_direction: The direction in which users are ordered

As of version 0.7 you can specify the sort direction, ascending or descending.

Valid values are "asc" or "ascending" (default) and "desc" or "descending".

Example: [authoravatars order=date_registered sort_direction=descending]

You can also use this shorter version:

Example: [authoravatars order=date_registered,desc]

render_as_list: Change the rendering template to a list. (deprecated)

This is deprecated since version 0.7.3. This option is probably going to be removed once a more advanced template system is in place. You can get the same effect by using userlist template filters as described in the Developers Guide.

Set this parameter to true, if you would like the list of users to be rendered using a html list (<ul>) instead of a bunch of <div>s. The plugin's default stylesheet renders these lists a normal list (avatars underneith each other) instead of all next to each other (float-ed).

Example: [authoravatars render_as_list=true]

The [show_avatar] shortcode

As of version 0.5 the plugin comes with a shortcode which can be used to show an avatar of any user using a userid or email address.

This is essentially only a wrapper for the get_avatar template function.

Basic example: [show_avatar email=mail@address.com]

Available Parameters

email and id

The value specified in the id or email attribute is passed as the first parameter to the get_avatar function.

Specify the email address of the user whose avatar you would like to display.

Example: [show_avatar email=mail@address.com]

avatar_size: The size of the avatar image

You can adjust the size of the avatar by specifying the avatar_size parameter.

Example: [show_avatar avatar_size=25]

align: The alignment of the avatar image

You can add an align attribute to display the avatar floated left/right or centered.

Possible values: left, right, center

Example: [show_avatar align=left]

Styling the show_avatar shortcode

Avatars shown using the show_avatar shortcode are wrapped into a div with the following classname: shortcode-show-avatar.

You can for example add the following bit of CSS code to your stylesheet to give the avatar an almost-white background and a grey border.

.shortcode-show-avatar {
  padding: 2px;
  background-color: #eee;
  border: 1px solid #ccc;