2016-04-27 4 views
-2

Here's what I got so far:So verwenden Sie sowohl PHP als auch Text in <a title link code?

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

+4

See one of [your very own previous questions](http://stackoverflow.com/questions/31106631/how-can-i-append-this-php-link-to-the-end-of-the-excerpt/31107378#31107378) on how to switch between PHP statement context and literal HTML sections. – mario

Antwort

3

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>'; 
+0

Or use shorthand '' – Hexchaimen

+0

brilliant! I used: echo '

'; – Hopelessone

+1

Ich habe das nicht hinzugefügt. nach dem php, (ich habe es nur vor dem php versucht und aufgegeben) – Hopelessone

Verwandte Themen