Still works… mostly
-
Although it’s old, it still works. However, as written, it expects a size and a class parameter. The small changes below remove that need.
/** * Shortcode for post thumbnail */ function post_thumbnail_shortcode($atts, $content='') { if(!function_exists('post_thumbnail_shortcode')) { return; } if(empty($atts['size'])) { $atts['size'] = 'thumbnail'; } if(empty($atts['class'])) { $atts['class'] = ''; } return '<span class="post_thumbnail '.$atts['class'].'">'.get_the_post_thumbnail(null,$atts['size']).'</span>'; } function post_thumbnail($str) { $args = wp_parse_args($str); echo post_thumbnail_shortcode($args); } add_shortcode('post_thumbnail', 'post_thumbnail_shortcode');
https://www.ads-software.com/plugins/add-post-thumbnail-shortcode/
- The topic ‘Still works… mostly’ is closed to new replies.