I’m having an issue with echo-ing a string with mutiple values/variables in it.
Here’s the PHP:
echo '" alt="'.the_title ().'"height="500px" width="940px"data-caption="#'.$post->ID.'" />';
echo '
<span class=" orbit-caption" id="'.$post->ID.'"><a href="'.$permalink.'"><h3>'.the_title ().'</h3></a><br /><p>'.wp_trim_excerpt().'</p></span>
';
And this results in this (one of five):
<img src= "http://msc-media.co.uk/wp-content/uploads/2012/07/wpid-IMAG00421.jpgDay Thirteen – Undissapointing French castles" alt=""height="500px" width="940px"data-caption="#178" />Day Thirteen – Undissapointing French castles
<span class=" orbit-caption" id="178"><a href="http://msc-media.co.uk/?p=178"><h3></h3></a><br /><p>We finally decided to take advantage our free entry to Peyrepetouse, the pictures say it all really! Was super windy near the top, so much so that the falconry show in the castle lost a few birds, which we watched fight the wind to try to get back to their masters for over 30 minutes, [...]</p></span>
The issue with this is that .the_title(). isn’t appearing in the alt=”” tag, but before, merging with the img src.
The second issue is that for span orbit-caption, the_title () has no output, as it should appear between the tags.
Let me know where I’m going wrong? – Or should I just split up this string into more echo-s?
Try to use
get_the_title();
Because
the_title()
doing something like, and doesn’t return a string.So it called before your echo call.