Slider Revolution WP
09.27.2016
This will create a new special shortcode that we can then add to the Post-based slider.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
function revslider_author_avatar( $atts ) { extract( shortcode_atts( array ( 'author' => 'admin', 'size' => '54', 'link' => '' ), $atts ) ); global $wpdb; $user = $wpdb->get_results( "SELECT ID FROM $wpdb->users WHERE display_name = '$author'" ); $author_id = $user[0]->ID; $author_link = get_author_posts_url( $author_id ); $author_avatar = get_avatar( $author_id, $size, '', $author ); $html = ''; if( $link === 'yes' ) $html .= '<a href="' . $author_link . '" title="' . $author . '">'; $html .= $author_avatar; if( $link === 'yes' ) $html .= '</a>'; return $html; } add_shortcode( 'revslider_avatar', 'revslider_author_avatar' ); |
1 2 3 |
[revslider_avatar author="{{author_name}}" size="54" link="yes"] |
size = The size of the avatar image in pixels (i.e. “54” would return an avatar size of 54×54)
link = Enter “yes” to link the avatar to the author’s page. Or enter “no” for no link.