Hopelessone Hopelessone - 2 years ago 61
PHP Question

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

Here's what I got so far:

//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?

Answer Source

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:


echo '<a title="Get updates from ' . get_the_author() . '" href="' . esc_url($facebook_profile) . '"><i class="fa fa-facebook"></i></a>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download