Advertisement
alchymyth

wp-caption at top

Apr 17th, 2011
683
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. /*
  2.  * move captions to top of image
  3.  * alchymyth 2011
  4.  */
  5. add_shortcode('wp_caption', 'top_caption_shortcode');
  6. add_shortcode('caption', 'top_caption_shortcode');
  7. function top_caption_shortcode($attr, $content = null) {
  8.         // Allow plugins/themes to override the default caption template.
  9.         $output = apply_filters('img_caption_shortcode', '', $attr, $content);
  10.         if ( $output != '' ) return $output;
  11.         extract(shortcode_atts(array(
  12.                 'id'=> '',
  13.                 'align' => 'alignnone',
  14.                 'width' => '',
  15.                 'caption' => ''), $attr));
  16.         if ( 1 > (int) $width || empty($caption) )
  17.         return $content;
  18.         if ( $id ) $id = 'id="' . esc_attr($id) . '" ';
  19.         return '<div ' . $id . 'class="wp-caption ' . esc_attr($align)
  20.         . '" style="width: ' . ((int) $width+ 10) . 'px">'
  21.         . '<p class="wp-caption-text">'
  22.         . $caption
  23.         . '</p>'
  24.         . do_shortcode( $content )
  25.         . '</div>';
  26.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement