I’m having a hard time turning a post in The Loop into a link. Basically I’m trying to make the displayed posts into links. The Loop automatically closes all my <a> tags and won’t let me turn the content of the_post() into one big link.
Here’s the problem code. This probably something simple I’m just overlooking.
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<a href="#" <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h3><?php the_title(); ?></h3>
</a>
<?php endwhile; ?>
*Edited to remove extraneous link.
Also, this is not valid HTML, it’s just test code for a proof-of-concept piece.
Your markup is completely invalid. You can not have an
<h3>, or any other block-level element, inside an<a>, and moreover you can’t have an<a>inside an<a>. This is not a WordPress issue, this is simply nonsense HTML.