我遇到了回显一个包含多个值/变量的字符串的问题。
这是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>
';
这导致了这个(五个中的一个):
<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_title()。没有出现在alt =“”标签中,但之前,与img src合并。 第二个问题是,对于span轨道标题,the_title()没有输出,因为它应该出现在标签之间。
让我知道我哪里出错了? - 或者我应该把这个字符串分成更多的echo-s?
答案 0 :(得分:4)
尝试使用get_the_title();
<强>由于强>
the_title()
执行类似的操作,但不返回字符串。
function the_title() { echo get_the_title(); }
所以它在你的回音之前打电话。