2012-08-05 2 views
1

값/변수가 여러 개인 문자열을 에코 처리하는 데 문제가 있습니다. (다섯 중 하나)문자열 값 변경 문자열에서 문자열 값 "the_title()"을 사용하여 스팅을 울릴 수 없음

  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> 
      '; 

그리고는이 결과 :

이 여기에 PHP의

<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와 병합됩니다. 두 번째 문제는 span 궤도 캡션에서 the_title()이 태그 사이에 나타나므로 출력이 없음을 나타냅니다.

어디에서 잘못 될지 알려주세요. - 아니면이 문자열을 더 많은 에코로 분할해야합니까?

답변

4

같은 일을 get_the_title();

the_title() 때문에 사용하는 시도하고 문자열을 반환하지 않습니다.

function the_title() { echo get_the_title(); } 

에코 호출 전에 호출되었습니다.

+0

완벽한 감사합니다. 내가 할 수 있으면 그것을 정확하게 표시 할 것이다 (타이머). – MChandler