1

WordPress 3.9.1, Bones Theme. I'm setting up an archive page for regular 'ol blog posts. The theory is to wrap each post's information in a permalink. Such as:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <a class="blog-article-permalink" href="<?php the_permalink() ?>">
        <article id="post-<?php the_ID(); ?>">
            <div class="article-thumbnail">
                <img src="" alt="">
                <p class="byline vcard"></p>
            </div>
            <div class="article-info">
                <header class="article-header">
                    <h2 class="article-title"><?php the_title(); ?></h2>
                </header>
                <section class="entry-content">
                    <p><?php the_excerpt(); ?></p>
                </section>
                <footer class="article-footer">
                    <p>...</p>
                </footer>
            </div>
        </article>
    </a>
<?php endwhile; ?>

When I load the page in any browser, I get:

<a class="blog-article-permalink">...</a>
<article id="post-3180">
    <a class="blog-article-permalink">...</a>
    <div class="article-thumbnail">
        <a class="article-permalink">...</a>
            <img src="" alt="">
        </a>
        <p class="byline vcard">
            <a class="blog-article-permalink">
               Byline Info
            </a>
        </p>
    </div>
    <div class="article-content">
        <header class="article-header">
            <h2 class="blog-archive-title">...</h2>
        </header>
        <section class="entry-content">
            <p>...</p>
        </section>
        <footer class="article-footer">
            <p>...</p>
        </footer>
    </div>
</article>

etc...

So basically, some part of WordPress is rearranging my carefully coded archive and outputting the link three times as it's own block-level-element and not allowing it to wrap the rest of the article information as intended.

I have 6 custom post types set up this way, and their archive pages look and work beautifully with get_posts(). I really want to use the generic loop for the blog, and not hack it up, because why would I?

I've read answers such as changing the valid children setting for the TinyMCE, and tried thinking that it may affect the loop somehow, but that didn't work. I guess it makes sense that it would invalidate block-level elements within an <a> link tag in html4, but we're using html5 now, where it's perfectly legal.

What am I missing here?

  • you're putting this markup directly in the post content editor? – Milo Jun 25 '14 at 1:24
  • No. I'm within the loop on the index.php file. – Rob Jun 25 '14 at 1:59
  • 1
    add your loop code to the question. WordPress doesn't alter html in the template, it gets passed straight to the browser as-is. – Milo Jun 25 '14 at 3:54
  • I don't see anything wrong with that code, in fact copying and pasting it directly into a theme template works for me. there's something elsewhere in your template causing the browser to reorder tags. – Milo Jun 25 '14 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.