I need to echo a lot of PHP and HTML.
I already tried the obvious, but it's not working:
<?php echo ' <?php if ( has_post_thumbnail() ) { ?> <div class="gridly-image"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail('summary-image', array('class' => 'overlay', 'title'=> the_title('Read Article ',' now',false) ));?></a> </div> <?php } ?> <div class="date"> <span class="day"> <?php the_time('d') ?></span> <div class="holder"> <span class="month"> <?php the_time('M') ?></span> <span class="year"> <?php the_time('Y') ?></span> </div> </div> <?php } ?>'; ?>
How can I do it?
Heredoc is one of the ways to store or print a block of text in PHP. The data stored in the heredoc variable is more readable and error-free than other variables for using indentation and newline. How the heredoc content can be stored in a variable or printed has shown in this tutorial.
The first is the concatenation operator ('. '), which returns the concatenation of its right and left arguments. The second is the concatenating assignment operator (' . = '), which appends the argument on the right side to the argument on the left side.
You don't need to output php
tags:
<?php if ( has_post_thumbnail() ) { echo '<div class="gridly-image"><a href="'. the_permalink() .'">'. the_post_thumbnail('summary-image', array('class' => 'overlay', 'title'=> the_title('Read Article ',' now',false) )) .'</a></div>'; } echo '<div class="date"> <span class="day">'. the_time('d') .'</span> <div class="holder"> <span class="month">'. the_time('M') .'</span> <span class="year">'. the_time('Y') .'</span> </div> </div>'; ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With