WordPress验证错误元素dl缺少子元素dd的必需实例

问题描述 投票:0回答:2
<dl class='gallery-item'>
<dt class='gallery-icon'>
                <a href='http://xxx.lt/wp-content/uploads/2013/02/snow-004.jpg' title='snow 004'><img width="200" height="81" src="http://xxx.lt/wp-content/uploads/2013/02/snow-004-200x81.jpg" class="attachment-thumbnail" alt="snow 004" /></a>
            </dt>
</dl>

在wordpress中,我插入shartcode [gallery link="file" columns="3"],当使用W3C验证站点时,出现错误Element dl is missing a required instance of child element dd。这是一个WordPress的错误?如何解决这个错误?也许在gallery_shortcode()中添加标签?

wordpress gallery shortcode
2个回答
0
投票

答案是Wordpress使用dd作为图像标题,请参见media.php中的代码。为图库中的每个图像添加标题,然后通过CSS中的“不显示”来删除标题。

<div class="my_class">    
 <div class='gallery'>
  <dl class='gallery-item'>
   <dt class='gallery-icon landscape'> 
    <img width="190" height="190" src="XXXX" class="attachment-thumbnail" alt="X" />
   </dt>
   <dd class='wp-caption-text gallery-caption'>Some Caption</dd>
  </dl>
 </div>
</div>

CSS:

.my_class .wp-caption-text.gallery-caption{
 display: none;
}

以防万一其他人正在寻找这个。有点混乱,但它可以工作。


0
投票

我知道这个问题很旧,但是我刚才遇到了同样的问题,当搜索google时,这是显示的第一页。

html验证程序给我有关图库的错误,我可以通过将以下代码添加到functions.php中来修复它-

add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'style', 'script' ) );
© www.soinside.com 2019 - 2024. All rights reserved.