Im using WordPress + WPML to translate. I need to insert a string (to be able of translating later) inside of a ALT that is inside of a php echo… I have tried using ” to separate html from php but seems that I’m missing something.
Putting this code inside the alt:
Gives an error.
Parse error: syntax error, unexpected '''' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';'
This is the code:
// START Condition Icon 1
$ico1 = get_post_meta($post->ID,'wpcf-ico-diving', true);
if ( $ico1)
{
echo '<li alt="'<?php
_e('Scuba Diving Tulum', 'aguaclaraproject');?>'" class="i1 icommon"></li>';
}
else {
// Show Nothing
} // END
I appreciate your help to allow me understand better how php works and solve this issue.
You’re already inside the php script, remove the php tags and concatenate it properly.
Or like this:
Or lastly: