Home Forums Front-end Issues Premature Closing of tag in Repeater Field


Premature Closing of tag in Repeater Field

  • Using this code

                        <?php if( have_rows('products') ): ?>
                         <?php while( have_rows('products') ): the_row(); ?>
                         <a href="<?php echo the_sub_field('product_link'); ?>">
                            <div class="category-prods col-sm-6" style="background-image: url('<?php echo the_sub_field('product_image'); ?>'); background-repeat: no-repeat; background-size: cover; background-position: top center;">
                                  <h1><a href="<?php echo the_sub_field('product_link'); ?>"><?php the_sub_field('product_title'); ?></a></h1>
                        <?php endwhile; ?>
                        <?php endif; ?>

    Can anyone tell me why the <a> tag is closing prematurely? There should only be an <a> tag wrapping the <div> and an <a> tag within the <h1> tag. Instead I’m getting extra <a> tags where they shouldn’t be.

  • because you have nested <a></a> tags. anchor tags cannot be nested inside of anchor tags

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.