
Sometimes we may want to display a block or snippet of HTML inside our WordPress theme or plugin. We can save this snippet to a PHP variable and call it anywhere, inside or outside a loop.
<?php ob_start(); ?> <span>Your HTML goes here</span> <?php $html = ob_get_clean(); ?>
Now you call the $html
variable anywhere in your code.