Hopelessone Hopelessone - 7 months ago 11
PHP Question

How to use both php and text in <a title link code?

Here's what I got so far:

<?php
//some other code
<a title="Get updates from 'echo get_the_author();'" href="' . esc_url($facebook_profile) . '"><i class="fa fa-facebook"></i></a>


I'm trying to echo get_the_author(); in the a title=, but get nothing,
what do I need to do to get it going?
Thanks,

Answer

You're going about it wrong. Don't mix like that, rather do something like:

<a title="Get updates from <?php echo get_the_author(); ?>" href="<?php  esc_url($facebook_profile); ?>"><i class="fa fa-facebook"></i></a>

If you're dead-set on using PHP to produce it, then you need to echo it out:

<?php

echo '<a title="Get updates from ' . get_the_author() . '" href="' . esc_url($facebook_profile) . '"><i class="fa fa-facebook"></i></a>';