Displaying Posts by tag dynamically in WordPress

The tag.php template shouldn’t use a custom query for its posts at all. When you visit the link to a tag the main query is automatically populated with posts that have that tag. In the template you output the main query with the standard loop.

<?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
        ... Display post content
    <?php endwhile; ?>
<?php endif; ?>

error code: 523