如果它对您来说是一个可用的选项,那么您可以更改[caption]
使用<span>
标记而不是<div>
.
下面是如何更改标题快捷码的输出(将添加到theme functions.php中):
// Source code from http://core.svn.wordpress.org/trunk/wp-includes/media.php
add_filter( \'img_caption_shortcode\', \'wpse57262_cleaner_caption\', 10, 3 );
function wpse57262_cleaner_caption( $output, $attr, $content ) {
if ( ! isset( $attr[\'caption\'] ) ) {
if ( preg_match( \'#((?:<a [^>]+>\\s*)?<img [^>]+>(?:\\s*</a>)?)(.*)#is\', $content, $matches ) ) {
$content = $matches[1];
$attr[\'caption\'] = trim( $matches[2] );
}
}
extract(shortcode_atts(array(
\'id\' => \'\',
\'align\' => \'alignnone\',
\'width\' => \'\',
\'caption\' => \'\'
), $attr));
if ( 1 > (int) $width || empty($caption) )
return $content;
if ( $id ) $id = \'id="\' . esc_attr($id) . \'" \';
$output = \'<span \' . $id . \'class="wp-caption \' . esc_attr($align) . \'" style="width: \' . (10 + (int) $width) . \'px">\'
. do_shortcode( $content ) . \'<p class="wp-caption-text">\' . $caption . \'</p></span>\';
return $output;
}
上述功能仅将标题图像的开头标记更改为
<span>
而不是
<div>
(请参见最后几行)。为了进一步优化字幕输出并使其更具可读性,
follow this excellent article by Justin Tadlock.
现在,这里有一个关于CSS应该如何的指针:
span.wp-caption {
display: inline-block;
/* add padding, margin, etc. as needed */
}