Created
September 22, 2018 10:27
-
-
Save temsool/62bdc238899a5a9520f45a242827c79f to your computer and use it in GitHub Desktop.
Put attachment via shortcode in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function put_attachment_image($atts) { | |
$atts = shortcode_atts( | |
array( | |
'id' => '1', | |
'title' => get_the_title($atts['id']), | |
'alt' => get_the_title($atts['id']), | |
'class' => '', | |
'size' => 'full', | |
), $atts | |
); | |
return wp_get_attachment_image($atts['id'], $atts['size'], false, array('title' => $atts['title'], 'alt' => $atts['alt'], 'class' => $atts['class'])); | |
} | |
add_shortcode('att-image', 'put_attachment_image'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment