How do I properly insert this php snippet within html? -


i have php snippet:

<div class="overlay-content"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <i class="fa fa-search"></i></a> </div> 

i remove:

<i class="fa fa-search"></i> 

and instead, insert title attribute, called via php, currently, font-awesome icon sits -- within hyperlink. way, when visitor hovers on item, see title instead of font awesome search icon.

so i've tried:

<div class="overlay-content"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_title_attribute(); ?></a> </div> 

and not successful reasons perhaps obvious php developers. i'm trying possible? guidance in helping me achieve appreciated!

the correct code, doesn't duplicate echo, should follows:

<div class="overlay-content">     <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">         <?php the_title(); ?>     </a> </div> 

as i've mentioned in comments, the_permalink() , the_title_attribute() echo content. no need add echo before each.

you should (usually) favor the_title() on the_title_attribute() actual display of title.


Comments