2012-08-05 76 views
1

我遇到了一个问题,它带有多个值/变量的字符串。无法在字符串中更改WP值“the_title()” - 字符串更改的顺序

这里的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 &#8211; Undissapointing French castles" alt=""height="500px" width="940px"data-caption="#178" />Day Thirteen &#8211; 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合并之前。 第二个问题是,对于跨度轨道标题,the_title()没有输出,因为它应该出现在标签之间。

让我知道我要去哪里错了? - 或者我应该把这个字符串分割成更多的echo-s?

回答

4

尝试使用get_the_title();

因为

the_title()做这样的事情,并不会返回一个字符串。

function the_title() { echo get_the_title(); } 

所以它在你的回声调用之前调用。

+0

完美,谢谢你。一旦我可以(计时器),我会标记它正确。 – MChandler 2012-08-05 15:29:38