文章标签内部的元素被重复10次,所有这些元素获得相同的类,ID等
问题描述:
tl; dr;一些在wordpress中运行的javascript将我的顶部元素全部复制到html中。见图片。文章标签内部的元素被重复10次,所有这些元素获得相同的类,ID等
嗨
我在这个错误在WordPress真的很惊讶,它实际上是相当容易复制。我想要一个
<a class="something" href="a-link"> ... </a>
包裹我所有的文章内容,使其看起来像这样的代码:
<article id="post-<?php the_ID(); ?>" <?php post_class('col-md-4'); ?>>
<a class="hehe" href="google.com">
<?php
if (is_sticky() && is_home() && ! is_paged()) {
printf('<span class="sticky-post">%s</span>', __('Featured', 'nisarg'));
} ?>
<?php nisarg_featured_image_disaplay(); ?>
<div class="main-image">
<?php if(get_field('main_image')): ?>
<img class="img-responsive " src="<?php the_field('main_image'); ?>" />
<?php endif; ?>
</div>
<?php if(get_field('vacation_type_image')): ?>
<img src="<?php the_field('vacation_type_image'); ?>" class="post-vacation-type" />
<?php endif; ?>
<header class="entry-header">
<div class="post-header">
<div class="row blog_post_container">
<div class="col-sm-12 blog_post_info_container_col">
<div class="blog_post_info_container">
<div class="blog_post_info_container_margin">
<span class="screen-reader-text"><?php the_title();?></span>
<?php if(is_single()) : ?>
<h1 class="entry-title blog_post_header"><?php the_title(); ?></h1>
<?php else : ?>
<h2 class="blog_post_info entry-title">
<?php the_title(); ?>
</h2>
<?php endif; // is_single() ?>
<?php if ('post' == get_post_type()) : ?>
<div class="entry-meta">
<h5 class="blog_post_info entry-date"><?php nisarg_posted_on(); ?></h5>
</div><!-- .entry-meta -->
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</header><!-- .entry-header -->
<div class="entry-summary row">
<div class="excerpt">
<?php the_excerpt(); ?>
<div class="excerpt-footer">
<div class="facebook-button">
<div class="fb-like"
data-share="true"
data-width="500"
data-show-faces="true">
<a class="fb-xfbml-parse-ignore"
target="_blank"
href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse">
</a>
</div>
</div>
</div>
</div>
</div><!-- .entry-summary -->
<!--<footer class="entry-footer">
<?php nisarg_entry_footer(); ?>
</footer> -->
</a>
</article><!-- #post-## -->
我现在用的是Nisarg主题,但如果我去的twentysixteen主题里面,把一个:
<a class="something" href="a-link"> ... </a>
里面的content.php它会有同样的效果,它抛出文章内的元素。像这样:
如果我在我的网页的源代码看,我没有看到任何这些额外的A类元素的,所以他们被一些JavaScript追加。现在,它发生在几个主题中的东西,我认为它与html5shiv有关...但是,我试图从等式中删除该脚本,但问题依然存在 - 所以我迷失了方向。有谁知道哪个JavaScript库可以做这样的事情?我也使用grep来查找a.cloneNode的JavaScript文件,但没有成功。
Twentysixteen,错误的复制:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="http://www.google.com" class="hehe">
<header class="entry-header">
<?php if (is_sticky() && is_home() && ! is_paged()) : ?>
<span class="sticky-post"><?php _e('Featured', 'twentysixteen'); ?></span>
<?php endif; ?>
<?php the_title(sprintf('<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url(get_permalink())), '</a></h2>'); ?>
</header><!-- .entry-header -->
<?php twentysixteen_excerpt(); ?>
<?php twentysixteen_post_thumbnail(); ?>
<div class="entry-content">
<?php
/* translators: %s: Name of current post */
the_content(sprintf(
__('Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentysixteen'),
get_the_title()
));
wp_link_pages(array(
'before' => '<div class="page-links"><span class="page-links-title">' . __('Pages:', 'twentysixteen') . '</span>',
'after' => '</div>',
'link_before' => '<span>',
'link_after' => '</span>',
'pagelink' => '<span class="screen-reader-text">' . __('Page', 'twentysixteen') . ' </span>%',
'separator' => '<span class="screen-reader-text">, </span>',
));
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php twentysixteen_entry_meta(); ?>
<?php
edit_post_link(
sprintf(
/* translators: %s: Name of current post */
__('Edit<span class="screen-reader-text"> "%s"</span>', 'twentysixteen'),
get_the_title()
),
'<span class="edit-link">',
'</span>'
);
?>
</footer><!-- .entry-footer -->
</a>
</article><!-- #post-## -->
生成的HTML:
,这样的手段,简单地增加AA标签在像content.php的商品标签之后将重复所有div中的标签,这些标签对我来说似乎都很疯狂。
由于
EDIT 1:添加例如具有确切相同的错误 “核心” wordpress主题twentysixteen的。
编辑2:我可以确认,Wordpress的干净安装有这个确切的问题。
答
在<h2>
标题中还有另一个<a>
。无法嵌套<a>
标签。 如果你这样做,浏览器尝试修复结构关闭嵌套的<a>
,你看到的结果是。