小编Nic*_* J.的帖子

Wordpress 3.9.x-从图形元素中删除行内宽度

从Wordpress 3.9开始,您可以向functions.php添加一行代码,以告诉Wordpress输出带有更多语义图和figcaption元素的带有标题的图像:

add_theme_support( 'html5', array(
'search-form', 'comment-form', 'comment-list', 'gallery', 'caption'
) );
Run Code Online (Sandbox Code Playgroud)

这很棒。但是由于某些原因,Wordpress为数字元素添加了宽度的内联样式,这阻止了整个单元的响应。那不是很好 我想向functions.php添加一些代码,以告诉Wordpress不包括行内宽度。

在media.php文件中,我找到了解决我的问题的标题简短代码:

$output = apply_filters( 'img_caption_shortcode', '', $attr, $content );
if ( $output != '' )
return $output;

$atts = shortcode_atts( array(
'id'      => '',
'align'   => 'alignnone',
'width'   => '',
'caption' => '',
'class'   => '',
), $attr, 'caption' );

$atts['width'] = (int) $atts['width'];
if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
return $content;

if ( ! empty( $atts['id'] ) )
$atts['id'] = 'id="' …
Run Code Online (Sandbox Code Playgroud)

php wordpress figure shortcode

3
推荐指数
1
解决办法
2089
查看次数

标签 统计

figure ×1

php ×1

shortcode ×1

wordpress ×1