gpt4 book ai didi

javascript - 文章标签内的元素被重复 10 次,所有这些元素都获得相同的类、id 等

转载 作者:行者123 更新时间:2023-12-03 06:28:17 25 4
gpt4 key购买 nike

tl;博士;在 WordPress 中运行的一些 JavaScript 会在整个 html 中重复我的顶部元素。参见图片。

我对 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&amp;src=sdkpreparse">
</a>
</div>
</div>
</div>
</div>

</div><!-- .entry-summary -->
<!--<footer class="entry-footer">
<?php nisarg_entry_footer(); ?>
</footer> -->
</a>
</article><!-- #post-## -->

我正在使用 Nisarg 主题,但如果我进入二十六个主题,并输入:

 <a class="something" href="a-link"> ... </a>

在 content.php 中它会产生相同的效果,它会散布在文章内部的元素中。像这样:

Littering a elements all over my code

如果我查看网页的源代码,我没有看到任何这些附加的 A 元素,因此它们被附加了一些 javascript。现在它出现在几个主题中,我认为它与 html5shiv 有关...但我试图从等式中删除该脚本,但问题仍然存在 - 所以我有点迷失了。有谁知道哪个 javascript 库可以做这样的事情?我还使用 grep 来查找执行 a.cloneNode 的 javascript 文件,但没有成功。

二十六,复制错误:

<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:

twentysixteen error replication

这意味着,只需在 content.php 之类的文章标签后面添加一个 a 标签,就会在所有 div 中复制 a 标签,这对我来说似乎很疯狂。

谢谢

编辑1:添加“核心”wordpress主题twentysixteen的示例,并出现完全相同的错误。

编辑2:我可以确认,全新安装的Wordpress 确实存在这个问题。

最佳答案

还有一个<a> <h2>内标题。无法嵌套<a>标签。如果您这样做,浏览器会尝试修复关闭嵌套 <a> 的结构。你看到的就是结果。

关于javascript - 文章标签内的元素被重复 10 次,所有这些元素都获得相同的类、id 等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38545066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com