2012-08-05 74 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