shoyebzz

WP shortcode with ATTS

Jun 2nd, 2017
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.35 KB | None | 0 0
  1. function random_picture($atts) {
  2.    extract(shortcode_atts(array(
  3.       'width' => 400,
  4.       'height' => 200,
  5.       'class'  => 'class_here'
  6.    ), $atts));
  7. //return '<img src="https://lorempixel.com/'. $width . '/'. $height . '" />';
  8. return '<span class="' . esc_attr($class) . '">' . $content . '</span>'
  9. }
  10.  
  11. add_shortcode('picture', 'random_picture');
Advertisement
Add Comment
Please, Sign In to add comment