php - Wordpress won't let me wrap a div in an a tag -
i'm having strange issue can't figure out. i'm working on custom theme in wordpress , i've got div image , icon image inside. i'm trying make both whole image , icon image within link.
the issue when try put link around whole div, wordpress closed link prematurely , adds second link - neither of enclosing div. if change div span, let me wrap in link. why?! going on , how , turn off 'feature'?
here selected code in template file:
<a href="<?php the_permalink(); ?>"> <div class="img"> <?php if (has_post_thumbnail()): ?> <img style="display: none;" src="<?php echo $image_attributes[0]; ?>" alt="<?php echo strip_tags(get_the_title()); ?>"> <span class="zoom hide-ie"><i class="fa fa-search"></i></span> <?php endif; ?> <?php if ($categories): ?> <a href="<?php echo get_category_link($categories[0] -> term_id )?>" class="category-link"><?php echo $categories[0]->cat_name?></a> <?php endif; ?> <div class="background" style="background-image: url('<?php echo $image_attributes[0]; ?>');"></div> </div> </a>
however, code being outputted browser:
<a href="http:somelink"> </a> <div class="img"> <a href="http:somelink"> <img style="display: none;" src="imagelink.jpg" alt="this isn’t our beautiful contest – how did here?"> <span class="zoom hide-ie"><i class="fa fa-search"></i></span> </a> <a href="categorylink/" class="category-link">agency mojo</a> <div class="background" style="background-image: url('http://imagelink.jpg');"></div> </div>
so can see, it's closing link immediately, , adding link inside of `
any amazing i've seen question asked not answered in few other places including here on site
i try avoid nesting anchor tags. perhaps work better.
<div class="img"> <?php if ( has_post_thumbnail() ): ?> <a href="<?php the_permalink(); ?>"> <img style="display: none;" src="<?php echo $image_attributes[0]; ?>" alt="<?php echo strip_tags(get_the_title()); ?>" /> <span class="zoom hide-ie"><i class="fa fa-search"></i></span> </a> <?php endif; ?> <?php if ($categories): ?> <a href="<?php echo get_category_link($categories[0]-> term_id ); ?>" class="category-link"> <?php echo $categories[0]->cat_name; ?> </a> <?php endif; ?> <a href="<?php the_permalink(); ?>"> <div class="background" style="background-image: url('<?php echo $image_attributes[0]; ?>');"></div> </a> </div>
Comments
Post a Comment