1. First outside your shortcode callback function just register the stylsheet and then in shortcode callback function enqueue it. like:- function wpsoe_191512_avatar_shortcode_wp_enqueue_scripts() { wp_register_style( 'get-avatar-style', plugins_url( '/css/style.css' , __FILE__ ), array(), '1.0.0', all ); } add_action( 'wp_enqueue_scripts', 'brw_avatar_shortcode_wp_enqueue_scripts' ); if ( function_exists( 'get_avatar' ) ) { function wpse_165754_user_avatar_shortcode ( $attributes ) { global $current_user; get_currentuserinfo(); extract(shortcode_atts(array( "id" => $current_user->ID, "size" => 32, "default" => 'mystery', "alt" => '', "class" => '', ), $attributes, 'get_avatar' )); $get_avatar= get_avatar( $id, $size, $default, $alt ); wp_enqueue_style( 'get-avatar-style' ); return '<span class="get_avatar '.$class.'">'.$get_avatar.'</span>'; } add_shortcode ('get_avatar', 'wpse_165754_user_avatar_shortcode'); } Above is the example. You can use yours. Thanks