不需要的<a> tags in Wordpress</a>

时间:2014-08-06 13:47:21

标签: php wordpress anchor

我对WordPress创建代码的方式有疑问。

如下所示,我的文章应该包含在<a>标记内。 WordPress创建了一些额外的包装,我不知道如何摆脱它们。

有没有人有想法?

此:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<article class="post-thumb">

    <a href="<?php the_permalink(); ?>">
        <?php if ( has_post_thumbnail() ) {the_post_thumbnail();} ?>
            <div class="post-thumb-caption">
                <h2><?php the_title(); ?></h2>
            </div>
            <div class="post-thumb-caption-hover">
                <div class="post-thumb-caption-hover-center">
                    <img id="menu-icon" class="icons svg" src="icons/menu21.svg"></img>
                    <h2><?php the_title(); ?></h2>
                    <h3><?php the_category(', ') ?></h3>
                </div>
            </div>
    </a>
</article>

<?php endwhile; ?>

<?php post_navigation(); ?>

<?php else : ?>

    <h2><?php _e('Nothing Found','html5reset'); ?></h2>

<?php endif; ?>

应该导致:

<article class="post-thumb">
    <a href="#">
        <img src="3a.jpg" id="image">
            <div class="post-thumb-caption">
                <h2>Titel</h2>
            </div>
            <div class="post-thumb-caption-hover">
                <div class="post-thumb-caption-hover-center">
                    <img id="menu-icon" class="icons svg" src="icons/menu21.svg">
                    <h2>Titel</h2>
                    <h3>Categorie</h3>
                </div>
            </div>
    </a>
</article>

但WordPress创建了这个:

<article class="post-thumb">

    <a href="http://localhost/sm/titel/">
        <img width="300" height="300" src="http://localhost/sm/wp-content/uploads/2014/08/3a.jpg" class="attachment-post-thumbnail wp-post-image" alt="3a">             <div class="post-thumb-caption">
                <h2>Titel</h2>
            </div>
            </a><div class="post-thumb-caption-hover"><a href="http://localhost/sm/Titel/">
                </a><div class="post-thumb-caption-hover-center"><a href="http://localhost/sm/Titel/">
                    <img id="menu-icon" class="icons svg" src="icons/menu21.svg">
                    <h2>Willem en Henk</h2>
                    </a><h3><a href="http://localhost/sm/Titel/"></a><a href="http://localhost/sm/category/ontbijt/" title="Alle berichten bekijken in Ontbijt" rel="category tag">Ontbijt</a>, <a href="http://localhost/sm/category/snacks/" title="Alle berichten bekijken in Snacks" rel="category tag">Snacks</a></h3>
                </div>
            </div>

</article>

1 个答案:

答案 0 :(得分:-1)

更改

<a href="<?php the_permalink(); ?>">

<a href="#">

它应该解决这个问题。